Page 1 of 1

What's wrong with my PHP code ?Help will be very appreciated

Posted: Wed Dec 07, 2011 1:09 pm
by phpcoder85
After the suggestion of the first reply I got , it still did not work . here is a short php code . I'm trying to pull my friends from twitter using the Twitter API with PHP , however , nothing gets displayed on the screen except for my NAME and my Twitter Picture . Can someone please tell me why it won't display my friends on twitter. I've been struggling to trigger the error for two days now .... Below is the code


Code: Select all

<?php
include 'lib/EpiCurl.php';
include 'lib/EpiOAuth.php';
include 'lib/EpiTwitter.php';
include 'lib/secret.php';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);

$twitterObj->setToken($_GET['oauth_tok…
$token = $twitterObj->getAccessToken();
$twitterObj->setToken($token->oauth_to… $token->oauth_token_secret);

// save to cookies
//setcookie('oauth_token', $token->oauth_token);
//setcookie('oauth_token_secret', $token->oauth_token_secret);

$twitterInfo= $twitterObj->get_accountVerify_credentia…
echo "<div class='welcome'>";
echo "<h5> Welcome, {$twitterInfo->name} </h5> <img src=\"{$twitterInfo->profile_image_url}\… 
";

try{
$friends = $twitterObj->get_statusesFriends();
$count = 10;
echo "<h2>Latest ".$count." Twitter Friends</h2>";
for ($i = 0; $i < $count; $i++) {
$friend = $friends->users[$i];
echo "<span><a title=\'".$friend->name."\' href='http://twitter.com/\'".
$friend->screen_name."\'><img class='following' src=\'".$friend->
profile_image_url."\' alt=\'".$friend->screen_name."\' height='48'
width='48' /></a>";
}
}
catch(EpiTwitterException $e) { echo "<p>You have no friends to ";}


?>

Re: What's wrong with my PHP code ?Help will be very appreci

Posted: Wed Dec 07, 2011 1:17 pm
by maxx99
I see you hardcoded your counter :)
Just us result of

Code: Select all

var_dump($twitterObj);

Re: What's wrong with my PHP code ?Help will be very appreci

Posted: Wed Dec 07, 2011 1:44 pm
by phpcoder85
Where am I supposed to add the var_dump($twitterObj) .. Thank you so much

Re: What's wrong with my PHP code ?Help will be very appreci

Posted: Thu Dec 08, 2011 6:38 am
by maxx99

Code: Select all

$friends = $twitterObj->get_statusesFriends();
var_dump($friends);
var_dump($twitterObj);