Need help with getting friends of Twitter user; using PHP and Epiphany RESTful PHP Framework
I am trying to get friends of the username I am passing in. Will not work, have tried everything I can think of. Please look over and give me some suggestions:
Although it gives no errors, a blank page is displayed. No usernames are echoed.
include 'lib/EpiCurl.php';
include 'lib/EpiOAuth.php';
include 'lib/EpiTwitter.php';
include 'lib/secret.php';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
$oauth_token = 'xxxx'; //Yes I filled these out in the actual code
$oauth_token_secret = 'xxxx'; //Yes I filled these out in the actual code
$twitterObj->setToken($oauth_token, $oauth_token_secret);
$twitterInfo= $twitterObj->get_accountVerify_credentials();
$twitterInfo->response;
$twitterUsername = $twitterInfo->screen_name;
getFriends('csti');
function getFriends ($username){
global $twitterObj, $oauth_token, $oauth_token_secret, $twitterUsername;
$twitterFriends = $twitterObj->get('/statuses/friends.json');
$twitterFriends->response; //not sure if this is necessary but doesnt work either way.
try{
foreach($twitterFriends as $friend) {
echo $friend->screen_name;
}
}catch(EpiTwitterException $e){
echo $e->getMessage();
}
开发者_StackOverflow中文版}
You've got a bit of weirdness in your code.
Your passing the parameter $username
and the string 'csti'
but you don't seem to be using it anywhere in the function.
精彩评论