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 git.master, git.master_jit
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 rfc.property-hooks
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

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
40.71 ms | 404 KiB | 8 Q