gpt4 book ai didi

php - twitter api (php) - 状态/销毁 - 不返回任何内容

转载 作者:行者123 更新时间:2023-12-04 04:52:52 24 4
gpt4 key购买 nike

我正在使用 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 文档指出您不必在帖子中发送 id - 但这没有任何区别。

我今天用两个不同的库对此进行了测试,但都不起作用。

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

最佳答案

根据 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);

关于php - twitter api (php) - 状态/销毁 - 不返回任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17164829/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com