PHP getting Twitter API JSON file contents without OAuth (Almost have it) -
hey guys, have script working fine oauth, accidentally nuked 350 api hits stupid while statement :( i'm trying data twitter api without oauth, can't figure out (still pretty new), heres have
<html> <body> <center> <hr /> <br /> <table border="1"> <tr><td>screenname</td><td>followed back?</td></tr> <?php //twitter oauth deets $consumerkey = 'x'; $consumersecret = 'x'; $oauthtoken = 'x'; $oauthsecret = 'x'; // create twitter api objsect require_once("twitteroauth.php"); $oauth = new twitteroauth($consumerkey, $consumersecret, $oauthtoken, $oauthsecret); //get home timeline tweets , stored array $youfollow = $oauth->get('http://api.twitter.com/1/friends/ids.json?screen_name=lccountdown'); $i = 0; //start loop print our results cutely in table while ($i <= 20){ $youfollowid = $youfollow[$i]; $resolve = "http://api.twitter.com/1/friendships/exists.json?user_a=".$youfollow[$i]."&user_b=jwhelton"; $followbacktest = $oauth->get($resolve); //$homedate= $hometimeline[$i]->created_at; //$homescreenname = $hometimeline[$i]->user->screen_name; echo "<tr><td>".$youfollowid."</td><td>".$followbacktest."</td></tr>"; $i++; } ?> </table> </center> </body> </html>
neither of 2 twitter functions require authentication, how can same results? guys, dex
you aren't calling making twitteroauth calls correctly. don't use full url method path , pass parameters in hash array.
you don't want use while loop when foreach work well.
<?php //twitter oauth deets $consumerkey = 'x'; $consumersecret = 'x'; $oauthtoken = 'x'; $oauthsecret = 'x'; // create twitter api objsect require_once("twitteroauth.php"); $oauth = new twitteroauth($consumerkey, $consumersecret, $oauthtoken, $oauthsecret); //get home timeline tweets , stored array $youfollow = $oauth->get('friends/ids', array('screen_name' => 'lccountdown')); $i = 0; //start loop print our results cutely in table foreach($youfollow $id){ $followbacktest = $oauth->get('friendships/exists', array('user_a' => $id, 'user_b' => 'jwhelton')); echo "<tr><td>".$id."</td><td>".$followbacktest."</td></tr>"; }
i have not directly tested should work. should consider moving fuller featured friendships/show method.
Comments
Post a Comment