【问题标题】:How to send a tweet from PHP with OAuth?如何使用 OAuth 从 PHP 发送推文?
【发布时间】:2010-10-30 15:35:54
【问题描述】:

那里有一些教程和课程,但自从 Twitter 更改为 oAuth 后,它们似乎不再有效。

如何以最基本的方式从 PHP 发送推文?

例如,使用 MyTwitter 类的“旧”方式如下:

require_once('MyTwitter.class.php');
$twitter =  new MyTwitter('username', 'password');
$message = "API Test.";
$result = $twitter->updateStatus($message);
print_r($result);

【问题讨论】:

    标签: php twitter oauth


    【解决方案1】:

    演示没有用,但类本身可以-

        $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET);
        $content = $connection->get('account/verify_credentials');
        $result = $connection->post('statuses/update', array('status' => $message));
    

    【讨论】:

      【解决方案2】:

      有一个实现 Twitter OAuth 的 good walkthrough here,并附有一个工作演示。如果您已经在使用框架,您可能还有其他选项,例如 Zend 框架中的Zend_Service_Twitter

      【讨论】:

      • 不幸的是,工作演示不起作用。它没有通过 oauth 令牌。
      猜你喜欢
      • 1970-01-01
      • 2010-10-31
      • 2011-12-14
      • 2011-05-10
      • 2012-05-16
      • 2011-09-03
      • 2018-05-05
      • 2013-10-11
      • 2012-10-27
      相关资源
      最近更新 更多