3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // Your ID and token $blogID = '8070105920543249955'; $authToken = 'OAuth 2.0 token here'; // The data to send to the API $postData = array( 'kind' => 'blogger#post', 'blog' => array('id' => $blogID), 'title' => 'A new post', 'content' => 'With <b>exciting</b> content...' ); // Create the context for the request $context = stream_context_create(array( 'http' => array( // http://www.php.net/manual/en/context.http.php 'method' => 'POST', 'header' => "Authorization: {$authToken}\r\n". "Content-Type: application/json\r\n", 'content' => json_encode($postData) ) )); // Send the request $response = file_get_contents('https://www.googleapis.com/blogger/v3/blogs/'.$blogID.'/posts/', FALSE, $context); // Check for errors if($response === FALSE){ die('Error'); } // Decode the response $responseData = json_decode($response, TRUE); // Print the date from the response echo $responseData['published'];
Output for 5.4.15 - 5.6.28, 7.0.0 - 7.1.0
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/7P8UU on line 26 Warning: file_get_contents(https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/7P8UU on line 26 Error
Output for hhvm-3.10.0 - 3.12.0
Warning: Failed to open https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/ (Could not resolve host: www.googleapis.com) in /in/7P8UU on line 26 Error
Output for 5.3.0 - 5.4.14
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/7P8UU on line 26 Warning: file_get_contents(https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/): failed to open stream: No such file or directory in /in/7P8UU on line 26 Error
Output for 5.2.0 - 5.2.17
Notice: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/7P8UU on line 26 Warning: file_get_contents(https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/): failed to open stream: No such file or directory in /in/7P8UU on line 26 Error
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_encode() in /in/7P8UU on line 21
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_encode() in /in/7P8UU on line 21
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_encode() in /in/7P8UU on line 21
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_encode() in /in/7P8UU on line 21