我有一个小应用程序,它使用(使用过)OAuth Echo和Tweetbot的自定义图像端点来自我托管我发布到Twitter的媒体。最近的API更新打破了应用程序,我似乎无法找到有关如何解决它的任何信息。
以下是我在更新之前使用的课程:
// Twitter oAuth Echo Class
// Author: http://shikii.net/blog/creating-a-custom-image-service-for-twitter-for-iphone/
class namespace_TwitterOAuthEcho
{
public $verificationUrl = "https://api.twitter.com/1/account/verify_credentials.json";
//isset($_SERVER['X-AUTH-SERVICE-PROVIDER']) ? $_SERVER['X-AUTH-SERVICE-PROVIDER'] : false;
public $userAgent = __CLASS__;
public $verificationCredentials;
/**
*
* @var int
*/
public $resultHttpCode;
/**
*
* @var array
*/
public $resultHttpInfo;
public $responseText;
/**
* Save the OAuth credentials sent by the Consumer (e.g. Twitter for iPhone, Twitterrific)
*/
public function setCredentialsFromRequestHeaders()
{
$this->verificationCredentials = isset($_SERVER['HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION'])
? $_SERVER['HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION'] : false;
}
/**
* Verify the given OAuth credentials with Twitter
* @return boolean
*/
public function verify()
{
$curl = curl_init($this->verificationUrl);
curl_setopt($curl, CURLOPT_USERAGENT, $this->userAgent);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: ' . $this->verificationCredentials,
));
$this->responseText = curl_exec($curl);
$this->resultHttpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$this->resultHttpInfo = curl_getinfo($curl);
curl_close($curl);
return $this->resultHttpCode == 200;
}
}
作为Twitter API新手,我不确定要改变什么才能让它再次运行。自2012年8月以来,Twitter's OAuth Echo文档尚未更新,因此没有帮助。
Twitter的API 1.1概述页面确实说all endpoints now require authorization。精细。我建立了一个新的应用程序;得到了我的消费者密钥/秘密。但是,我不确定那些去哪儿。在Twitter上编辑应用程序设置时,我也不确定应该在这里设置什么设置。我的应用程序(我认为)实际上不需要与Twitter进行交互。我只是想将一个URL发送回Tweetbot(任何Twitter客户端),以便它可以将它放在推文中。
非常感谢任何有关更新此内容的帮助。谢谢。
答案 0 :(得分:3)
替换
public $verificationUrl = "https://api.twitter.com/1/account/verify_credentials.json";
with
public $verificationUrl = "https://api.twitter.com/1.1/account/verify_credentials.json";
多数民众赞成。您只需要更改URL。也无需更改您的Twitter APP。它也适用于你的旧APP。