Twitter API (php) -状态/销毁-不返回任何东西


twitter api (php) - statuses/destroy - returns nothing

我正在使用tmOAuth库。

使用新的1.1 API,下面的代码返回一个错误代码400——但是身份验证已经完成了(对状态进行了相同的身份验证)!我使用的库对所有调用都很好,除了这个!

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

twitter API文档说明你不必在post中发送id -但这没有任何区别。

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

有什么建议吗?有谁知道它有问题吗?

根据您的评论,您已经在1.1 API的两个库中进行了测试。

你还没有在这一个测试它。这里是说明,尽管你似乎已经有了你的证件。

这基本上证明你正在使用的库有问题,而不是twitter API。所以,要么在github上提交一个bug报告(否则他们怎么知道?),要么使用另一个库,比如上面的库。

使用上述库所需的确切代码(并且它有效,我刚刚测试了它):

// 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);

如果您正在使用Abraham Williams的twitteroauth php库并试图删除旧的tweet/转发,则需要构造post()查询:

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