PHP Instagram User Image Fetcher
In this post PHP Instagram User Image Fetcher we’ll show you the way to create a simple Instagram user image fetcher in PHP by mistreatment Instagram REST API. This application can use Instagram API to fetch recent twenty photos of public users with the similar name.
It conjointly displays likes of every ikon. Please note that you simply will solely access photos of users WHO create their profile public mistreatment this API.
For PHP Instagram User Image If you’re not at home with REST then REST stands for objective State Transfer that could be a approach of accessing net services. a lot of then seventy fifth of net services use REST.
you’ll access a REST service by employing a easy HTTP GET or POST requests. The API provide output most likely in JSON format and you’ll decipher it in PHP and use it in your application.
I will create a tutorial on a way to create your own REST API in PHP shortly. If you’re desirous to learn the way to make associate Instagram Location Image Fetcher mistreatment Google map API and Instagram API you’ll read the elaborated tutorial on it by visiting following link.
Now lets starts PHP Instagram User Image Fetcher
Get Latest Image by mistreatment Instagram API for PHP Instagram User Image
The Instagram API’s needs associate ACCESS TOKEN. Here is that the REST API URL. The output is additionally in JSON Format.
{user-id}/media/recent/?access_token=ADD-ACCESS-TOKEN
Note: initial API is employed to fetches users id’s of the user with similar username and also the second API is employed to fetch recent twenty pictures of that user.
Now so as to induce access token, there area unit once more 2 strategies
First Method for PHP Instagram User Image Fetcher
First Method for PHP Instagram User Image Fetcher :: for Register your app in Instagram developer console https://www.instagram.com/developer/
and find access token by mistreatment once more mistreatment GET Request like below
https://instagram.com/oauth/authorize/?client_id=56df9______b9cad&redirect_uri=http://localhost/test/instagram/&response_type=token&scope=basic+public_content+follower_list+comments+relationships+likes
But this access token are often accustomed fetch your own data solely not the other users. so as to fetch public users data you would like to submit your app on Instagram that could be a terribly complicated method therefore the second method
Second method (Recommended and Easy) for PHP Instagram User Image Fetcher
Just visit the subsequent link to induce the Access Token for PHP Instagram User Image.
Once you get the access token then you’ll simply fetch pictures of users by business on top of 2 API’s mistreatment PHP script as given below.
The Complete Code for PHP Instagram User Image Fetcher
hear is code for PHP Instagram User Image and get photo form Instagram using php code with easy way.
<?php if(!empty($_POST['username'])) { // add MY-ACCESS-TOKEN $add_access_token = "51-MY-ACCESS-TOKEN-3e"; $set_userid_url = 'https://api.instagram.com/v1/users/search?q='.urlencode($_POST['username']).'&access_token='.$add_access_token; $set_userid_json = file_get_contents($set_userid_url); $set_userid_array = json_decode($set_userid_json,true); } ?> <!DOCTYPE html> <html lang="en"> <head> <title>PHP Instagram User Image Fetcher - onlinecode</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- bootstrap css --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <!-- jquery js --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <!-- bootstrap js --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="jumbotron text-center subdiv"> <h1>PHP Instagram User Image Fetcher - onlinecode</h1> </div> <div class="container subdiv"> <div class="row subdiv"> <div class="subdiv col-md-8 col-md-offset-2"> <form action="" method="POST"> <div class="subdiv form-group"> <label for="location">Name of User</label> <input type="text" class="subdiv form-control" name="username" value="<?php if(!empty($_POST['username'])) { echo $_POST['username']; } ?>"> </div> <button type="submit" class="subdiv btn btn-primary btn-block">Search Instagram Photos</button> </form> </div> </div> <div class="row subdiv"> <?php if(!empty($set_userid_array)) { ?> <div class="subdiv col-md-8 col-md-offset-2"> <?php $set_count=0; foreach($set_userid_array['data'] as $id_val) { if($set_count==3) break; $set_count++; $get_userid = $id_val['id']; $get_username = $id_val['full_name']; echo "<hr>"; echo "<b>$get_username<b>"; echo "</br> </br>"; // hear Turn off reporting of error error_reporting(0); $instagram_url = "https://api.instagram.com/v1/users/".$get_userid."/media/recent/?access_token=".$access_token; $instagram_json = file_get_contents($instagram_url); $instagram_array = json_decode($instagram_json,true); if(!empty($instagram_array)) { foreach($instagram_array['data'] as $image_val) { ?> <div class="subdiv well col-md-12"> <img class="subdiv img-responsive" style="padding-left:35px;" src="<?php echo $image_val['images']['standard_resolution']['url'] ?>" alt="Instagram Photos"> </div> <div class="subdiv col-md-12"> <p>Number Of Likes : <?php echo $image_val['likes']['count'] ?></p> </div> <?php } // end foreach for instagram_array } // end if for empty check } // end foreach } // end if ?> </div> </div> </div> </body> </html>
You also like google recaptcha using javascript and google recaptcha using php and PDO using Prepared Statements a Complete Reference and PHP Create Instagram location Image Fetcher