3v4l.org

run code in 300+ PHP versions simultaneously
<?php //INCLUDE YOUR LIST OF TWEETS AS AN ARRAY SIMILAR TO THE FOLLOWING $tweets = array( "524980794709016576", "524980794503495680", "524980792699940864" ); define('CONSUMER_KEY', "sHKRfEvXFJ3Avr3OWbkdIhkjV"); define('CONSUMER_SECRET', "HmNw6VbkFVHGObjCzYOqynz9V8NdIYlgnRcJ8K2sclLnD44dUv"); $x = base64_encode(rawurlencode(CONSUMER_KEY). ":".rawurlencode(CONSUMER_SECRET)); $url = "https://api.twitter.com/oauth2/token"; $opts = array( 'http'=>array( 'method'=>"POST", 'header'=>"Authorization:Basic $x\r\n". "Content-Type: application/x-www-form-urlencoded;charset=UTF-8.", 'content'=>"grant_type=client_credentials" ) ); $context = stream_context_create($opts); $output = file_get_contents($url,false,$context); $result = json_decode($output,true); $access_token = $result['access_token']; $query = urlencode("alibaba"); //include your query $search_url = "https://api.twitter.com/1.1/search/tweets.json?q=$query&result_type=recent&count=10"; $output = file_get_contents($search_url,false,stream_context_create(array( 'http'=>array( 'method'=>"GET", 'header'=>"Authorization:Bearer $access_token")))); $results = json_decode($output,true); //results returned as JSON $results = $results['statuses']; $c= 0; foreach ($results as $result) { $id = $result['id_str']; print $id; print "!!!"; $RTCount = $result['retweet_count']; if ($RTCount > 0) { $RTid = $result['retweeted_status']['id_str']; $tweet_url = "https://api.twitter.com/1.1/statuses/retweets/$RTid.json?count=1"; $output = file_get_contents($tweet_url,false,stream_context_create(array( 'http'=>array( 'method'=>"GET", 'header'=>"Authorization:Bearer $access_token")))); $retweets = json_decode($output,true); //results returned as JSON $last_RT = $retweets[0]['retweet_count']; } else { $last_RT = "!!!"; } //print "$tw\t$id\t$RTCount\t$last_RT\n"; } ?>
Output for 8.3.0 - 8.3.7
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 25 Warning: file_get_contents(): open_basedir restriction in effect. File(https://api.twitter.com/oauth2/token) is not within the allowed path(s): (/tmp:/in:/etc) in /in/i0fkM on line 25 Warning: file_get_contents(https://api.twitter.com/oauth2/token): Failed to open stream: Operation not permitted in /in/i0fkM on line 25 Warning: Trying to access array offset on null in /in/i0fkM on line 27 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 32 Warning: file_get_contents(): open_basedir restriction in effect. File(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10) is not within the allowed path(s): (/tmp:/in:/etc) in /in/i0fkM on line 32 Warning: file_get_contents(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10): Failed to open stream: Operation not permitted in /in/i0fkM on line 32 Warning: Trying to access array offset on null in /in/i0fkM on line 37 Warning: foreach() argument must be of type array|object, null given in /in/i0fkM on line 39
Output for 8.2.0 - 8.2.18
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 25 Warning: file_get_contents(): open_basedir restriction in effect. File(https://api.twitter.com/oauth2/token) is not within the allowed path(s): (/tmp:/in:/etc) in /in/i0fkM on line 25 Warning: file_get_contents(https://api.twitter.com/oauth2/token): Failed to open stream: Operation not permitted in /in/i0fkM on line 25 Warning: Trying to access array offset on value of type null in /in/i0fkM on line 27 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 32 Warning: file_get_contents(): open_basedir restriction in effect. File(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10) is not within the allowed path(s): (/tmp:/in:/etc) in /in/i0fkM on line 32 Warning: file_get_contents(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10): Failed to open stream: Operation not permitted in /in/i0fkM on line 32 Warning: Trying to access array offset on value of type null in /in/i0fkM on line 37 Warning: foreach() argument must be of type array|object, null given in /in/i0fkM on line 39
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 25 Warning: file_get_contents(): open_basedir restriction in effect. File(https://api.twitter.com/oauth2/token) is not within the allowed path(s): (/tmp:/in:/etc) in /in/i0fkM on line 25 Warning: file_get_contents(https://api.twitter.com/oauth2/token): Failed to open stream: Operation not permitted in /in/i0fkM on line 25 Warning: Trying to access array offset on value of type null in /in/i0fkM on line 27 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 35 Warning: file_get_contents(): open_basedir restriction in effect. File(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10) is not within the allowed path(s): (/tmp:/in:/etc) in /in/i0fkM on line 35 Warning: file_get_contents(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10): Failed to open stream: Operation not permitted in /in/i0fkM on line 35 Warning: Trying to access array offset on value of type null in /in/i0fkM on line 37 Warning: foreach() argument must be of type array|object, null given in /in/i0fkM on line 39
Output for 8.0.13
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 25 Warning: file_get_contents(https://api.twitter.com/oauth2/token): Failed to open stream: No such file or directory in /in/i0fkM on line 25 Warning: Trying to access array offset on value of type null in /in/i0fkM on line 27 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 35 Warning: file_get_contents(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10): Failed to open stream: No such file or directory in /in/i0fkM on line 35 Warning: Trying to access array offset on value of type null in /in/i0fkM on line 37 Warning: foreach() argument must be of type array|object, null given in /in/i0fkM on line 39
Output for 7.4.33
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 25 Warning: file_get_contents(https://api.twitter.com/oauth2/token): failed to open stream: No such file or directory in /in/i0fkM on line 25 Notice: Trying to access array offset on value of type null in /in/i0fkM on line 27 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 35 Warning: file_get_contents(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10): failed to open stream: No such file or directory in /in/i0fkM on line 35 Notice: Trying to access array offset on value of type null in /in/i0fkM on line 37 Warning: Invalid argument supplied for foreach() in /in/i0fkM on line 39
Output for 7.4.0 - 7.4.32
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 25 Warning: file_get_contents(): open_basedir restriction in effect. File(https://api.twitter.com/oauth2/token) is not within the allowed path(s): (/tmp:/in:/etc) in /in/i0fkM on line 25 Warning: file_get_contents(https://api.twitter.com/oauth2/token): failed to open stream: Operation not permitted in /in/i0fkM on line 25 Notice: Trying to access array offset on value of type null in /in/i0fkM on line 27 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 35 Warning: file_get_contents(): open_basedir restriction in effect. File(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10) is not within the allowed path(s): (/tmp:/in:/etc) in /in/i0fkM on line 35 Warning: file_get_contents(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10): failed to open stream: Operation not permitted in /in/i0fkM on line 35 Notice: Trying to access array offset on value of type null in /in/i0fkM on line 37 Warning: Invalid argument supplied for foreach() in /in/i0fkM on line 39
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 7.3.32 - 7.3.33
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 25 Warning: file_get_contents(https://api.twitter.com/oauth2/token): failed to open stream: No such file or directory in /in/i0fkM on line 25 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 35 Warning: file_get_contents(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10): failed to open stream: No such file or directory in /in/i0fkM on line 35 Warning: Invalid argument supplied for foreach() in /in/i0fkM on line 39
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 25 Warning: file_get_contents(): open_basedir restriction in effect. File(https://api.twitter.com/oauth2/token) is not within the allowed path(s): (/tmp:/in:/etc) in /in/i0fkM on line 25 Warning: file_get_contents(https://api.twitter.com/oauth2/token): failed to open stream: Operation not permitted in /in/i0fkM on line 25 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 35 Warning: file_get_contents(): open_basedir restriction in effect. File(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10) is not within the allowed path(s): (/tmp:/in:/etc) in /in/i0fkM on line 35 Warning: file_get_contents(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10): failed to open stream: Operation not permitted in /in/i0fkM on line 35 Warning: Invalid argument supplied for foreach() in /in/i0fkM on line 39
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/i0fkM on line 25 Warning: file_get_contents(https://api.twitter.com/oauth2/token): failed to open stream: No such file or directory in /in/i0fkM on line 25 Notice: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 35 Warning: file_get_contents(https://api.twitter.com/1.1/search/tweets.json?q=alibaba&result_type=recent&count=10): failed to open stream: No such file or directory in /in/i0fkM on line 35 Warning: Invalid argument supplied for foreach() in /in/i0fkM on line 39
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Notice: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/i0fkM on line 25 Warning: file_get_contents(https://api.twitter.com/oauth2/token): failed to open stream: No such file or directory in /in/i0fkM on line 25 Fatal error: Call to undefined function json_decode() in /in/i0fkM on line 26
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Warning: file_get_contents() expects at most 2 parameters, 3 given in /in/i0fkM on line 25 Fatal error: Call to undefined function: json_decode() in /in/i0fkM on line 26
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Warning: file_get_contents() expects at most 2 parameters, 3 given in /in/i0fkM on line 25 Fatal error: Call to undefined function: json_decode() in /in/i0fkM on line 26
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: file_get_contents() expects at most 2 parameters, 3 given in /in/i0fkM on line 25 Fatal error: Call to undefined function: json_decode() in /in/i0fkM on line 26

preferences:
238.28 ms | 402 KiB | 460 Q