doulian8554 2013-09-24 18:51
浏览 59

使用OAuth在CodeIgniter中基于Twitter ID检索Twitter数据

I am using a script to fetch data of a particular Twitter user id. The twitter user id is 1897279429.

I want to show its name and image. I have the following script using the Twitter library.

        $this->load->config('twitter');
        require_once APPPATH.'libraries/TwitterAPIExchange.php';
        $settings = array(
            'oauth_access_token' => $this->config->item('access_token'),
            'oauth_access_token_secret' => $this->config->item('access_token_secret'),
            'consumer_key' => $this->config->item('consumer_key'),
            'consumer_secret' => $this->config->item('consumer_secret')
        );


        /** Perform a GET request and echo the response **/
        /** Note: Set the GET field BEFORE calling buildOauth(); **/
        $url = 'https://api.twitter.com/1.1/followers/ids.json';
        $getfield = '?username=SaswatRoutroy';
        $requestMethod = 'GET';
        $twitter = new TwitterAPIExchange($settings);
        echo $twitter->setGetfield($getfield)
                    ->buildOauth($url, $requestMethod)
                    ->performRequest();

The issue is that I want the name and the URL of the profile picture to be displayed, but instead I get the following:

{"ids":[],"next_cursor":0,"next_cursor_str":"0","previous_cursor":0,"previous_cursor_str":"0"}

Now it may be because I don't have any follower, and the URL is wrong. But I want the appropriate way and URL.

  • 写回答

1条回答

  • doukaizha5417 2013-09-29 19:27
    关注

    It's not just you. I just put that user ID into a Twython script I have to look them up and got this:

    bash-3.2$ ./id-show.py 
    User to show: 1897279429
    Traceback (most recent call last):
      File "./id-show.py", line 14, in <module>
        data = twitter.show_user(user_id=target)
      File "build/bdist.macosx-10.3-fat/egg/twython/endpoints.py", line 426, in show_user
      File "build/bdist.macosx-10.3-fat/egg/twython/api.py", line 230, in get
      File "build/bdist.macosx-10.3-fat/egg/twython/api.py", line 224, in request
      File "build/bdist.macosx-10.3-fat/egg/twython/api.py", line 194, in _request
    twython.exceptions.TwythonError: Twitter API returned a 403 (Forbidden), User has been suspended.
    bash-3.2$ 
    

    So there you have it, whoever that was has been suspended.

    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值