I am using the Facebook Graph API to get the genders from a list of Facebook users. I have the user's IDs (they are current users of my app). For this, I won't need to use the API because gender does not require special permissions (even though I have obtained the basic info permissions anyhow). Basically I'm using a while loop to loop through all the rows on a MySQL table which has stored the FB ids that I grabbed when the user uses the app. When I do the json_decode code outside the while loop, it works great (but obviously only grabs the first instance in the table). Then when I put it in a loop, the page just won't load. It just sits and tries to load forever. Here's the code:
$sql = "SELECT * FROM fb_id ORDER BY timestamp DESC"; $result = $mysqli->query($sql); while($row = mysqli_fetch_array($result)){ $jsonurl = "https://graph.facebook.com/".$row['fb_id']; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json); $user_gender = $json_output->gender; echo $user_gender; } while($row = mysqli_fetch_array($result)){ echo "<a href='http://www.facebook.com/".$row['fb_id']."' target='_blank'><img src='http://graph.facebook.com/".$row['fb_id']."/picture/' /></a>"; } You'll see the top bit of code is for the gender. The bottom loop is to display the user's profile pictures. That bottom loop works fine.
Any ideas why the call to the Facebook Graph would be getting stuck? Thanks!