Twitter打印错误的屏幕名称

时间:2015-05-25 16:26:32

标签: php twitter twitter-oauth

我需要登录Twitter,然后我需要发布一些Twitter。我按照不同的例子,我在推特上发了一条推文。我在twitter上用我的用户名person1创建应用程序。在twitter person2上创建另一个帐户后,当我发布推文时,我的程序读起来就像屏幕名称person1而不是person2。我像API https://github.com/abraham/twitteroauth一样使用  我的登录名是:

if(isset($_SESSION['name']) && isset($_SESSION['twitter_id'])) //check whether user already logged in with twitter
{

    echo "Name :".$_SESSION['name']."<br>";
    echo "Twitter ID :".$_SESSION['twitter_id']."<br>";
    echo "Image :<img src='".$_SESSION['image']."'/><br>";
    echo "<br/><a href='logout.php'>Logout</a>";


}
else // Not logged in
{

    $connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET);
    $request_token = $connection->getRequestToken($OAUTH_CALLBACK); //get Request Token

    if( $request_token)
    {
        $token = $request_token['oauth_token'];
        $_SESSION['request_token'] = $token ;
        $_SESSION['request_token_secret'] = $request_token['oauth_token_secret'];

        switch ($connection->http_code) 
        {
            case 200:
                $url = $connection->getAuthorizeURL($token);
                //redirect to Twitter .
                header('Location: ' . $url); 
                break;
            default:
                echo "Coonection with twitter Failed";
                break;
        }

    }
    else //error receiving request token
    {
        echo "Error Receiving Request Token";
    }


}

推特的另一课:

$connection = new TwitterOAuth ( CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET );
$content = $connection->get ( "account/verify_credentials" );

$tweets = $connection->get ( 'https://api.twitter.com/1.1/statuses/user_timeline.json?screenNamecount'$content->screen_name'=10' );

当我打印屏幕名称时,结果是person1而不是person2,其中person2是用户当前登录的。有人可以帮帮我吗?

0 个答案:

没有答案