【发布时间】:2013-10-13 15:15:06
【问题描述】:
最近我读了一篇很好的教程How to Authenticate Users With Twitter OAuth,即使它是在更改 Twitter ID 格式之前编写的,但它也适用于新的 Twitter ID 格式。
我有一些问题,请解释一下是否有人成功完成了..
-
为什么我们总是调用两个方法
getRequestToken和getAccessToken?是得到access token和access token secret吗?但两者都已经在下面的页面给出了......http://dev.twitter.com/apps/{your_app_id}/my_token.
request token和request token secret到底需要什么??虽然我注意到每次处理时两个令牌都不同。
-
如果我们从下面的方法更新我们的状态
$connection->post( 'statuses/update', array('status' => 'some message got from text area value' );
那我们如何验证状态是否已成功更新?这意味着如果我想显示警报消息post has been sent successfully,我如何在我们的 PHP 页面中实现它??
-
哪个回调 URL 很重要,即用户在 Twitter 上发布或做事后实际导航到哪里?
-
是在开发应用程序时写的URL
Registered OAuth Callback URLhttp://dev.twitter.com/apps/{id_no}
或 -
是不是我们的 php 代码中定义的 URL (
config.php) 之类的define('OAUTH_CALLBACK', 'http://www.xyz.com');
再来一个Q'n
-
- 拒绝应用程序访问如何处理?
注意:请参考我的Question regarding this
@Thai 更新
我按照你的建议做了以下
$user_info = $connection->get('account/verify_credentials');
$status_info =$connection->get('statuses/show/', array('id' =>32320907720523776) );
echo "<pre>";
print_r($status_info);
echo "</pre> Content : <pre>";
print_r($user_info);
返回下方
stdClass Object
(
[request] => /1/statuses/show.json?id=3.2320907720524E%2B16&oauth_consumer_key=jashak..&oauth_nonce=bec...&oauth_signature=%2FMj%2B0Z7oyYNKdMn%2B%2FOJ6Ba8ccfo%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1296541384&oauth_token=223961574-cW4...&oauth_version=1.0a
[error] => No status found with that ID.
)
注意: 为了安全起见,我隐藏了 oauth_consumer key、oauth_nonce 和 oauth_token ;)
Content:
stdClass Object
(
[follow_request_sent] =>
[profile_link_color] => 038543
[profile_image_url] => http://a3.twimg.com/profile_images/1215444646/minialist-photography-9_normal.jpg
[contributors_enabled] =>
[favourites_count] => 31
[profile_sidebar_border_color] => EEEEEE
[id_str] => 223961574 // this is also id_str
[status] => stdClass Object
(
[retweeted] =>
[id_str] => 32320907720523776 // this id_str i used
[in_reply_to_status_id_str] =>
[geo] =>
[contributors] =>
[source] => Black Noise
[in_reply_to_user_id_str] =>
[retweet_count] => 0
[truncated] =>
[coordinates] =>
[created_at] => Tue Feb 01 06:14:39 +0000 2011
[favorited] =>
[text] => Twitter test: verify that status has been updated
[place] =>
[in_reply_to_screen_name] =>
[in_reply_to_status_id] =>
[id] => 3.2320907720524E+16
[in_reply_to_user_id] =>
)
[screen_name] => ltweetl
[profile_use_background_image] => 1
....
...
我收到了错误No status found with that ID,你提到了哪个id_str??
【问题讨论】:
标签: php twitter-oauth