开发者

Need help with getting friends of Twitter user; using PHP and Epiphany RESTful PHP Framework

开发者 https://www.devze.com 2023-03-29 02:04 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消