Twitter API: Allow accept request to follow authen

2019-03-28 04:56发布

I have a protected twitter account due to the age restricted content being displayed. Is there a way to use the twitter API to accept or reject the requests to follow this account. I know that I can view these requests using

http://api.twitter.com/version/friendships/incoming.json

but which request will accept a request. I was looking at the

http://api.twitter.com/version/friendships/create.json

request but this seams to follow a user rather than accept the request for them to follow me.

标签: php api twitter
2条回答
霸刀☆藐视天下
2楼-- · 2019-03-28 05:13

Unfortunately, there is no method for doing this using the API for now.

http://code.google.com/p/twitter-api/issues/detail?id=8 has a request for it, but it seems to have a very low priority.

查看更多
可以哭但决不认输i
3楼-- · 2019-03-28 05:18

With the knowledge that the Twitter web uses it's own API to power it, using a dummy account (@komski and @GdRd) to send a follow request to another, and in clicking the accept button... Twitter sent a HTTP POST request to:

http://api.twitter.com/1/friendships/accept.json

With the following parameters:

user_id: 18828908
post_authenticity_token: cbb345597daaa0d7b3cce63e4d3014818be75627

And the response was a JSON object of the new follower:

{"following":true,"profile_sidebar_fill_color":"DDEEF6","id_str":"18828908","profile_background_tile":false,"profile_image_url":"http:\/\/a3.twimg.com\/profile_images\/1194797142\/Book-Cover-question2-150x150_1__normal.jpg","description":"@reply\/mention me in message and a book's ISBN and I'll reply back it's Goodreads.com rating!","status":{"text":"@komski The Time Traveler's Wife is rated 3.94 stars by 8966 people via @goodreads","id_str":"19777104837087232","truncated":false,"source":"\u003Ca href=\"http:\/\/sudocode.net\/apps\/post-pig\" rel=\"nofollow\"\u003EPost Pig\u003C\/a\u003E","geo":null,"favorited":false,"created_at":"Tue Dec 28 15:30:03 +0000 2010","place":null,"in_reply_to_screen_name":"komski","in_reply_to_user_id":14653828,"in_reply_to_status_id":19775098961526784,"in_reply_to_status_id_str":"19775098961526784","coordinates":null,"contributors":null,"retweeted":false,"id":19777104837087232,"in_reply_to_user_id_str":"14653828","retweet_count":0},"is_translator":false,"contributors_enabled":false,"url":"http:\/\/sudocode.net\/projects\/book-ratings-twitter-bot\/","show_all_inline_media":false,"follow_request_sent":false,"geo_enabled":false,"profile_link_color":"0084B4","followers_count":69,"screen_name":"GdRd","friends_count":81,"profile_sidebar_border_color":"C0DEED","location":"The Internet","lang":"en","statuses_count":29,"verified":false,"notifications":false,"profile_use_background_image":true,"created_at":"Sat Jan 10 06:38:09 +0000  2009","listed_count":5,"profile_background_color":"C0DEED","protected":false,"profile_background_image_url":"http:\/\/a3.twimg.com\/a\/1298664727\/images\/themes\/theme1\/bg.png","favourites_count":0,"name":"GdRd","id":18828908,"time_zone":"Taipei","utc_offset":28800,"profile_text_color":"333333"}

Now, I'm assuming that when using OAuth, you could try omitting the post_authenticity_token when sending the request.

查看更多
登录 后发表回答