I have a PHP script that displays Tweets embedded in a site I built out on my local machine. When I uploaded the site to my IIS 8.0 server, the PHP script no longer works and I receive this error:
Warning: Invalid argument supplied for foreach() in C:\inetpub\wwwroot\i360_new\footer.php on line 76
The script is:
<?php ini_set('display_errors', 1); require_once('TwitterAPIExchange.php'); /** Set access tokens here - see: https://dev.twitter.com/apps/ **/ $settings = array( 'oauth_access_token' => "xxxxx", 'oauth_access_token_secret' => "xxxxx", 'consumer_key' => "xxxxx", 'consumer_secret' => "xxxxx" ); /** Perform a GET request and echo the response **/ /** Note: Set the GET field BEFORE calling buildOauth(); **/ $url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; $getfield = '?screen_name=interactive360&count=1'; $requestMethod = 'GET'; $twitter = new TwitterAPIExchange($settings); $string = json_decode($twitter->setGetfield($getfield) ->buildOauth($url, $requestMethod) ->performRequest(),$assoc = TRUE); foreach($string as $items) { echo $items['text']."<br />"; } ?>
I thought it might be a PHP version issue but my local machine is running 5.4.10 and my server is running 5.4.14.
Answer
Did you compare both servers phpinfo()? While running in almost the same environment each server can work differently depending on which modules are installed.
Attribution
Source : Link , Question Author : user715564 , Answer Author : kworr