5

我正在尝试创建一个 Web 应用程序,该应用程序允许用户直接在网页上从表单发布推文,而不是使用 Twitter 自己的预构建弹出窗口。问题是,我在网上看到的代码片段不起作用:

$message = "Hello there! This is a tweet!";

$twitterObj->post('statuses/update', array('status' => "$message"));

当我尝试执行代码时,出现此错误:

警告:在第 76 行的 /twitter/EpiOAuth.php 中为 foreach() 提供了无效参数

警告:http_build_query() [function.http-build-query]:参数 1 应为数组或对象。/twitter/EpiOAuth.php 第 140 行中给出的值不正确

我正在构建示例并使用在此网址上找到的 OAuth 库:

http://www.jaisenmathai.com/articles/twitter-php-sign-in.html

有没有人有任何提示?


编辑

问题解决了!事实证明,这是我需要使用的正确语句:

$twitterObj->post_statusesUpdate(array('status' => 'Message goes here.'));
4

1 回答 1

2

这就是我使用的:

$message = "Hello there! This is a tweet!";

$twitterObj->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => $message), 'POST');

这是在这里找到的库:https ://github.com/abraham/twitteroauth

于 2012-05-07T16:40:29.147 回答