[英]How to send a tweet from PHP with OAuth?
There's a few tutorials and classes out there but they no longer appear to work since Twitter changed to oAuth. 那里有一些教程和课程,但是自从Twitter更改为oAuth以来,它们似乎不再起作用。
How do I send a tweet from PHP, in the most basic way possible? 如何以最基本的方式从PHP发送推文?
For example, the 'old' way using the MyTwitter class was as follows: 例如,使用MyTwitter类的“旧”方式如下:
require_once('MyTwitter.class.php');
$twitter = new MyTwitter('username', 'password');
$message = "API Test.";
$result = $twitter->updateStatus($message);
print_r($result);
The demo didn't work, but the class itself did- 该演示无法正常运行,但课堂本身可以进行以下操作:
$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));
Theres a good walkthrough here of implementing Twitter OAuth, complete with a working demo. 这里是实现Twitter OAuth的很好的演练 ,并带有一个有效的演示。 If you're already using a framework you probably have other options also such as
Zend_Service_Twitter
in Zend Framework 如果您已经在使用框架,则可能还有其他选项,例如Zend Framework中的
Zend_Service_Twitter
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.