PHP twitter API not working...

Hoping someone can help me debug this:

http://anxietyclown.com/TwitterO/feed_test.php

That page SHOULD bring up the tweets in a twitter feed but instead just brings up the actual code from that I am calling as a library. My understanding is that this means PHP isn’t active on the server but then when I run a php test I get this:

http://anxietyclown.com/TwitterO/phptest.php

Which tells me its on…right?

Sorry noooob question…

not really sure why its showing the php code, but you’re missing a file, there’s an error message at the very bottom of the page

Fatal error: Class ‘TwitterOAuth’ not found in /homepages/20/d98661292/htdocs/travelgeek/TwitterO/feed_test.php on line 14 and there’s a comment near the top of the page that a file needs to be downloaded.

When I visit http://anxietyclown.com/TwitterO/phptest.php all I see is a copy of the github project page so I’m not really able to see your code.

If you paste your code here people will be able to debug it. I haven’t used twitteroauth but I’ll be happy to look at the it and try and get it working on my end. However if we can’t see your code we won’t be able to tell you where the problem is, how it got fixed, and sometimes why the changes fixed it… Which is crucial to the learning process.

I think the reason you’re seeing the ‘fatal error’ is that the file thats MISSING is the file that’s displaying on the page. I’m calling an external library and instead of incorporating the library, it’s displaying it. here’s my code:

[php]<?php
session_start();
require_once(“twitteroauth/twitteroauth/twitteroauth.php”); //Path to twitteroauth library you downloaded in step 3

$twitteruser = “jdroberto”; //user name you want to reference
$notweets = 5; //how many tweets you want to retrieve

$consumerkey = “xxxxxxxxx”;
$consumersecret = “xxxxxxxxx”;
$accesstoken = “xxxxxxxxx”;
$accesstokensecret = “xxxxxxxxx”;

function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
$connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
return $connection;
}

$connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);

$tweets = $connection->get(“https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser."&count=”.$notweets);

echo json_encode($tweets);
echo $tweets; //testing remove for production
?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service