0

これは簡単な質問ですが、Twitter のフォロワー数を取得するためのコードを参照する次の php ファイルがあります。これはすべて機能しますが、HTML Web サイト ファイルで「フォロワー数」をテキストとして表示したいのですが、PHP ではどの行を追加すればよいかわかりません。私はすでにHTMLで参照されているスクリプトを持っています。現在、それを使用して取得しようとして<span id="followers_count"></span>いますが、何も表示されません。私はそれを間違っていますか、それともフォロワー数を取得してHTMLにテキストとして表示するには、phpファイルに何を追加すればよいですか? ありがとう!

<?php   
    require_once('js/twitter-api-php/TwitterAPIExchange.php');

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

    $ta_url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
    $getfield = '?screen_name=inovize;
    $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;

    *Do I add anything here to take followers_count to html text?*


    });
4

1 に答える 1