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.

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?