จำนวนผู้ติดตามทวิตเตอร์

วิธีเดียวที่จะได้รับจำนวนผู้ติดตามในรูปแบบข้อความธรรมดาคือการใช้ cURL หรือไม่ หรือ twitter API มีตัวเลือกดังกล่าวหรือไม่


person user1117313    schedule 30.12.2011    source แหล่งที่มา


คำตอบ (3)


https://api.twitter.com/1/users/lookup.json?screen_name=tvdw (โปรไฟล์ของฉัน แค่เปลี่ยนชื่อหน้าจอ)

พร้อมใช้งานในรูปแบบ XML ด้วย: https://api.twitter.com/1/users/lookup.xml?screen_name=tvdw

รับมันใน PHP:

$data = json_decode(file_get_contents('https://api.twitter.com/1/users/lookup.json?screen_name=tvdw'), true);
echo $data[0]['followers_count'];
person Tom van der Woerdt    schedule 30.12.2011
comment
ฉันเชื่อว่าบรรทัดสุดท้ายควรเป็น echo $data[0]['followers_count']; - person Eli; 29.03.2012

ใน API เวอร์ชัน 1.1 คุณสามารถใช้: https://dev.twitter.com/docs/api/1.1/get/users/show

ช่อง 'followers_count' ควรมีหมายเลขจำนวนผู้ติดตาม

ใน API เวอร์ชัน 1 ซึ่งเลิกใช้แล้ว คุณสามารถใช้: https://dev.twitter.com/docs/api/1/get/users/show

person myyk    schedule 12.01.2013

Twitter API 1.0 เลิกใช้งานแล้วและไม่มีการใช้งานอีกต่อไป ด้วย REST 1.1 API คุณต้องมีการตรวจสอบสิทธิ์ oAuth เพื่อดึงข้อมูลจาก Twitter

ใช้สิ่งนี้แทน:

<?php
    require_once('TwitterAPIExchange.php'); //get it from https://github.com/J7mbo/twitter-api-php

    /** Set access tokens here - see: https://dev.twitter.com/apps/ **/
    $settings = array(
        'oauth_access_token' => "YOUR_OAUTH_ACCESS_TOKEN",
        'oauth_access_token_secret' => "YOUR_OAUTH_ACCESS_TOKEN_SECRET",
        'consumer_key' => "YOUR_CONSUMER_KEY",
        'consumer_secret' => "YOUR_CONSUMER_SECRET"
    );

    $ta_url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
    $getfield = '?screen_name=REPLACE_ME';
    $requestMethod = 'GET';
    $twitter = new TwitterAPIExchange($settings);
    $follow_count=$twitter->setGetfield($getfield)
    ->buildOauth($ta_url, $requestMethod)
    ->performRequest();
    $data = json_decode($follow_count, true);
    $followers_count=$data[0]['user']['followers_count'];
    echo $followers_count;
?>
person Alisher Ahmatovich    schedule 16.10.2014