【问题标题】:Twitter api - POST statuses/filter with OAuthTwitter api - 使用 OAuth 发布状态/过滤器
【发布时间】:2013-05-29 11:11:41
【问题描述】:

现在我使用此代码从 twitter 获取流,它工作正常。 但是很快带有用户和密码的基本身份验证将被弃用,我如何使用 oauth 发送此请求?

$fp = fsockopen("ssl://stream.twitter.com", 443, $errno, $errstr, 30);
            if (!$fp)
            {
                echo "ERROR: Twitter Stream Error: failed to open socket";
            } else
            {


                $request  = "GET /1.1/statuses/filter.json?track=";
                $request .= urlencode(implode($_keywords, ',')) . " HTTP/1.1\r\n";
                $request .= "Host: stream.twitter.com\r\n";
                $request .= "Authorization: Basic ";
                $request .= base64_encode($this->m_username . ':' . $this->m_password);
                $request .= "\r\n\r\n";

【问题讨论】:

    标签: php twitter-oauth


    【解决方案1】:

    您可以使用 tmhOAuth 之类的东西来轻松实现这样的目标。

    在此处找到库:https://github.com/themattharris/tmhOAuth

    使用 filter.json 的示例: https://github.com/themattharris/tmhOAuth-examples/blob/master/streaming.php

    您还需要一个应用程序,注册/登录(使用您的普通 Twitter 帐户)并通过以下方式创建一个:https://dev.twitter.com

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-09
      • 2015-06-12
      • 2016-05-22
      • 2016-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多