PHP to html with twitter api 1.1 -
this simple question have following php file references code twitter follower count. works in html website file want display "follower count" text , in php not sure line add. have script referenced in html , right trying using <span id="followers_count"></span>
nothing appears. doing wrong or add php file take follower count , display text in html? thanks!
<?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 add here take followers_count html text?* });
you echoing out count ever code resides in php code, @ top of page.
echo $followers_count;
comment out line
//echo $followers_count;
and have span echo line
<span id="followers_count"><?php echo $followers_count; ?></span>
Comments
Post a Comment