Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Oauth发布Tweet_Php_Html_Forms_Twitter_Oauth - Fatal编程技术网

Php 使用Oauth发布Tweet

Php 使用Oauth发布Tweet,php,html,forms,twitter,oauth,Php,Html,Forms,Twitter,Oauth,我正在尝试创建一个web应用程序,允许用户直接在网页上发布来自表单的tweet,而不是使用Twitter自己预先构建的弹出窗口。问题是,我在网上看到的代码片段不起作用: $message = "Hello there! This is a tweet!"; $twitterObj->post('statuses/update', array('status' => "$message")); 当我尝试执行代码时,我得到以下错误: 警告:为第76行/twitter/epiouth.

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

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

$twitterObj->post('statuses/update', array('status' => "$message"));
当我尝试执行代码时,我得到以下错误:

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

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

我以该示例为基础,使用位于以下网址的OAuth库:

有人有什么建议吗


编辑

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

$twitterObj->post_statusesUpdate(array('status' => 'Message goes here.'));
这就是我使用的:

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

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

这是在此处找到的库:

谢谢您的帮助!我用你的代码替换了我的代码,看起来错误已经消失了,但它仍然没有发布tweet。所以它可以识别,但看起来并不是在执行它。你是否在Twitter端为你的应用程序启用了写访问权限?是的,为了测试目的,我将其设置为“读、写和访问直接消息”,然后将其拨回“读和写”,但它仍然不起作用。我需要在“OAuth工具”下编辑任何内容吗这实际上取决于您使用的OAuth库。这使用