Guest User

Untitled

a guest
Apr 26th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. <?php
  2.  
  3. $hostname='localhost';
  4. $username='root';
  5. $password='';
  6. $database='jsondb';
  7.  
  8. $conn=mysqli_connect($hostname,$username,$password,$database) or die ('Connecting to Mysql failed');
  9.  
  10. $jsonCont = file_get_contents('https://graph.facebook.com/186622721684184?fields=posts{id,full_picture,created_time,from,message}&access_token=');
  11.  
  12. $content = json_decode($jsonCont, true);
  13. for($x = 0; $x <= 24; $x++){
  14.  
  15. $id = $content['posts']['data'][$x]['id'];
  16. $message = $content['posts']['data'][$x]['message'];
  17. $name = $content['posts']['data'][$x]['from']['name'];
  18. $full_picture = $content['posts']['data'][$x]['full_picture'];
  19. $created_time = $content['posts']['data'][$x]['created_time'];
  20.  
  21. mysqli_query($conn,"insert into fbjsontable value('$id', '$message', '$name', '$full_picture', '$created_time')");
  22. }
  23.  
  24. ?>
  25.  
  26. isset($content['posts']['data'][$x]['full_picture'])?$fullpicture=$content['posts']['data'][$x]['full_picture']:$fullpicture='';
  27.  
  28. isset($content['posts']['data'][$x]['full_picture'])?$fullpicture=$content['posts']['data'][$x]['full_picture']:$fullpicture='Image not found';
  29.  
  30. $full_picture = $content['posts']['data'][$x]['full_picture'] ?? null;
Add Comment
Please, Sign In to add comment