Twitter API检测固定的推文

时间:2016-01-14 14:33:23

标签: php twitter twitter-oauth

有没有办法使用twitter api返回的数组检测固定的推文?我有print_r返回的数组,没有任何内容表明推文是否被固定。

我目前使用的方法是

$statuses = $connection->get("statuses/home_timeline", array("count" => 25, "exclude_replies" => true));

该文档未提及固定推文https://twitteroauth.com/

3 个答案:

答案 0 :(得分:4)

用户个人资料在过去的某个时刻显示了固定推文,但不再显示。

https://api.twitter.com/1.1/users/show.json?id=2705321

"has_extended_profile": true,
"default_profile": false,
"default_profile_image": false,
"pinned_tweet_ids": [
  451484520316153860
],
"has_custom_timelines": false,

答案 1 :(得分:1)

不,目前无法使用公共Twitter API检测或设置固定的推文。

答案 2 :(得分:0)

没有办法通过API,但从网站上抓取数据相当容易*。 HTML有许多有用的语义属性,你可以使用它们。

这是我的固定推文的HTML表示。

<div 
    class="tweet original-tweet js-original-tweet js-stream-tweet js-actionable-tweet js-profile-popup-actionable cards-forward
    user-pinned" 
    data-tweet-id="554772317738659840"
    data-disclosure-type=""
    data-item-id="554772317738659840"
    data-permalink-path="/edent/status/554772317738659840"
    data-screen-name="edent"
    data-name="Terence Eden" 
    data-user-id="14054507"
    ...

使用课程<div>查找user-pinned - 然后获取属性data-tweet-id。这将是固定的状态ID。

*首先检查T&amp; Cs!