Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $hostname='localhost';
- $username='root';
- $password='';
- $database='jsondb';
- $conn=mysqli_connect($hostname,$username,$password,$database) or die ('Connecting to Mysql failed');
- $jsonCont = file_get_contents('https://graph.facebook.com/186622721684184?fields=posts{id,full_picture,created_time,from,message}&access_token=');
- $content = json_decode($jsonCont, true);
- for($x = 0; $x <= 24; $x++){
- $id = $content['posts']['data'][$x]['id'];
- $message = $content['posts']['data'][$x]['message'];
- $name = $content['posts']['data'][$x]['from']['name'];
- $full_picture = $content['posts']['data'][$x]['full_picture'];
- $created_time = $content['posts']['data'][$x]['created_time'];
- mysqli_query($conn,"insert into fbjsontable value('$id', '$message', '$name', '$full_picture', '$created_time')");
- }
- ?>
- isset($content['posts']['data'][$x]['full_picture'])?$fullpicture=$content['posts']['data'][$x]['full_picture']:$fullpicture='';
- isset($content['posts']['data'][$x]['full_picture'])?$fullpicture=$content['posts']['data'][$x]['full_picture']:$fullpicture='Image not found';
- $full_picture = $content['posts']['data'][$x]['full_picture'] ?? null;
Add Comment
Please, Sign In to add comment