2013-06-18 52 views
1

我正在使用tmOAuth库。twitter api(php) - 状态/销毁 - 不返回

使用新的1.1 API,以下是返回错误代码400 - 但验证已完成(相同的身份验证工作)!我使用的图书馆适用于所有通话,除此之外!

$tmhOAuth->request(
    'POST', $tmhOAuth->url('https://api.twitter.com/1.1/statuses/destroy/MYIDHERE.json'), 
    array(
     'id' => MYIDHERE 
    ) 
); 

twitter API文档声明,您不必在发送后发送id,但这没有任何区别。

我今天用两个不同的库测试了这个,但都没有工作。

任何建议 - 有谁知道是否有问题吗?

+0

提交错误报告,在GitHub上的供应商,在“问题”选项卡。 – Jimbo

+0

现在在2 api中测试 - 不能是一个简单的api错误 –

+0

安迪,这是一个图书馆问题 - 你测试过的那些不起作用。看到我的答案。 – Jimbo

回答

0

根据your comment,您已在两个库中对1.1 API进行了测试。

虽然您还没有在this one中进行过测试。说明here,虽然你似乎已经拥有了你的凭证。

这基本上证明你使用的库存在问题,而不是twitter API。因此,要么提交github上的错误报告(他们还有什么要知道的?),或者使用另一个类似上面的库。使用上述库所需

确切的代码(和它的作品,我只是测试它):

// Require the library file 
require_once('TwitterAPIExchange.php'); 

// Set up your credentials 
$settings = array(
    'oauth_access_token' => "YOUR_TOKEN", 
    'oauth_access_token_secret' => "YOUR_TOKEN_SECRET", 
    'consumer_key' => "YOUR_CONSUMER_KEY", 
    'consumer_secret' => "YOUR_CONSUMER_SECRET" 
); 

// Put the correct ID in the URL 
$url = 'https://api.twitter.com/1.1/statuses/destroy/YOURIDHERE.json'; 

// Set the request type 
$requestMethod = 'POST'; 

// Set the post fields 
$postfields = array('id' => 'YOURIDHERE'); 

// Make the request 
$twitter = new TwitterAPIExchange($settings); 
$json = $twitter->buildOauth($url, $requestMethod) 
       ->setPostfields($postfields) 
       ->performRequest(); 

// Dump the response 
$result = json_decode($json); 
var_dump($result); 
+0

完美 - 你的权利 - 它的工作原理应该如此。 ;)从计算出错误中获得了更多的时间! –

+0

也许'$ postfields'不是必需的:所有的信息都在url中。 – Asenar

+0

@Asenar如果所有的信息都在url中,那么这是一个GET请求。大声笑。 – Jimbo

0

如果您使用从亚伯拉罕·威廉姆斯twitteroauth的PHP库,并试图删除旧的鸣叫/转推你需要构建post()查询这样:

$response = $connection->post('statuses/destroy/'.$tweetID, array()); //Curl url output = statuses/destroy/$tweetID.json 
+0

非常感谢! – Asenar