Twitter App not working from new server


#1

Hi Guys,

Let me first state that I’m quite new to the whole app development scene. With some help of my dear friend Google I managed to create a nice twitter feed for my clients website. I used my own web hosting provider while developing the site, and everything worked perfectly. When I moved the complete site, with working app, to the clients web provider the app stopped working!

I can’t seem to find the exact error, that’s why I wanted to ask you guys for help. I’ll post as much information as I can. So I used PHP to build the site and I use the following files for my app:

  • Index.php
  • Twitterfeed.php

So my index.php contains:

...
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script type="text/javascript" src="js/twitter-widget.js"></script>
...
<body>
<?php include_once("twitterfeed.php") ?>
...
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="TwitterContainer">
 <tr>
  <td align="left" valign="top">
   <!-- Begin Twitter Feed Area  -->
   <div id="tweet"></div>               
   <!-- End Twitter Feed Area  -->
  </td>
 </tr>
</table>
...
</body>

the Twitterfeed.php file contains the following code:

<?
require_once('TwitterAPIExchange.php');

$settings = array(
    'oauth_access_token' => "***",
    'oauth_access_token_secret' => "***",
    'consumer_key' => "***",
    'consumer_secret' => "***"
);

$url = 'https://api.twitter.com/1.1/statuses/mentions_timeline.json';
$getfield = '?count=5';
$requestMethod = 'get';
$twitter = new TwitterAPIExchange($settings);
$feed = $twitter->setGetfield($getfield)
             ->buildOauth($url, $requestMethod)
             ->performRequest();

$cache = dirname(__FILE__) . '/cache/twitter-json.txt';

$last = filemtime($cache);
$now = time();
$interval = 3600; //update every hour

// check the cache file
if ( !$last || (( $now - $last ) > $interval) ) {
	$cachefile = fopen($cache, 'w');
	fwrite($cachefile,utf8_encode($feed));
	fclose($cachefile);
	//echo("Succesfully written to file");
}
?>

Final result is that my cache file is empty after this script has run. The web provider of my client already tested the connection from the server to Twitter, no problems there. Is there any other way of debugging or testing?

Thanks in advance!


#2

PS The consumer_key, consumer_key_secret, oauth_access_token and oauth_access_token_secret are filled in my files but I removed them from this post.


#3

If it’s possible, I would check what the raw response is that you’re getting when using your performRequest() function. There’s like a status code and error giving some indication as to what’s up.

Maybe there’s an SSL issue? Is your timestamp current?


#4

Hi Taylor, my appologies for the late reply. How can I see the raw response of the performRequest() function?


#5

Did anyone find a solution to this? I’m having a similar problem.

Using twitterAPIExchange.php, just using users/show.json code, the problem I’m having is the on my MAMP it works fine (on my computer) but as soon as I push it to my server (WAMP, hosted in the US on a server by my company) it’s returning ‘boolean false’

Best,

Rich