Twitter Print an Wrong Screen Name

流过昼夜 提交于 2019-12-24 20:58:41

问题


I need to log in twitter and after I need to post a little twitter. I follow different example and I have posted a tweet on my twitter. I create the application in twitter with my username person1.After I create another account on twitter person2 and when I post the tweet my program read like screen name person1 and not person2. I use like API https://github.com/abraham/twitteroauth My log in is:

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


}

Another class to tweet:

$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' );

when I print screen name the result is person1 and not person2 where person2 it's the user currently logged. Anyone can help me?

来源:https://stackoverflow.com/questions/30442389/twitter-print-an-wrong-screen-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!