PHP获取用户信息Twitter API

时间:2014-08-27 13:24:35

标签: php html twitter

我想知道你是否可以帮助我。

我目前正在尝试使用' GET用户/节目'在Twitter API中的命令,但它不起作用。

谁能看到我哪里出错了?

<?php include "library/twitteroauth.php"; ?>
<?php
$consumer = "key";
$consumersecret = "key";
$accesstoken = "key";
$accesstokensecret = "key";

$twitter = new TwitterOAuth($consumer, $consumersecret, $accesstoken, $accesstokensecret);
$tweets = $twitter->get('https://api.twitter.com/1.1/users/lookup.json?screen_name=twitterapi,twitter');

?>

<html>
    <head>
            <meta charset ="UTF-8" />
            <title>Twitter Search</title>       
    </head>
        <body>
            <form action="" method="post">
            <label>Search: <input type="text" name ="keyword"/>
            </form>
            <?php 
            if ( isset($_POST['keyword'])){
                $tweets = $twitter->get('https://api.twitter.com/1.1/users/lookup.json?screen_name='.$_POST['keyword']. '');
                foreach($tweets as $tweet){
                    foreach ($tweet as $t){
                        echo ($t->text);
                    }
                    }
                    }           

            ?>
        </body>
</html>

感谢您的帮助。

我收到的错误讯息:

Notice: Undefined property: stdClass::$text in C:\wamp\www\tutorial\twitterapi - Copy\index.php on line 27

var_dump($ tweets)之后的错误消息

    oobject(stdClass)[33]
  public 'errors' => 
    array (size=1)
      0 => 
        object(stdClass)[34]
          public 'message' => string 'Sorry, that page does not exist' (length=31)
          public 'code' => int 34

0 个答案:

没有答案