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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpcoder85
Forum Newbie
Posts: 3
Joined: Wed Dec 07, 2011 12:48 am

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

Post 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 ";}


?>
Last edited by Benjamin on Wed Dec 07, 2011 6:39 pm, edited 1 time in total.
Reason: Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.
maxx99
Forum Contributor
Posts: 142
Joined: Mon Nov 21, 2011 3:40 am

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

Post by maxx99 »

I see you hardcoded your counter :)
Just us result of

Code: Select all

var_dump($twitterObj);
phpcoder85
Forum Newbie
Posts: 3
Joined: Wed Dec 07, 2011 12:48 am

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

Post by phpcoder85 »

Where am I supposed to add the var_dump($twitterObj) .. Thank you so much
maxx99
Forum Contributor
Posts: 142
Joined: Mon Nov 21, 2011 3:40 am

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

Post by maxx99 »

Code: Select all

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