Tuesday 15 January 2019

How to get instagram feed in custom page in magento

<?php
$fields = array(
'client_id' => "bdb4fd62e6e24f938fb7d124acf80187",
'client_secret' => "1cca64ded0e046118b311fdc001bb52c",
'grant_type' => "authorization_code",
'redirect_uri' => "http://wgi-mobile-dev-949798541.ap-south-1.elb.amazonaws.com/insta.php",
//'code' => $_GET['code'],
);
//1484074220.1677ed0.af32987ae8984bb59d9803afabc83e65
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.instagram.com/v1/users/self/media/recent/?access_token=1484074220.1677ed0.af32987ae8984bb59d9803afabc83e65');
curl_setopt($ch, CURLOPT_POST, false);
//curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$posts = curl_exec($ch);
curl_close($ch);
$posts = json_decode($posts);

if ($posts) {
foreach ($posts->data as $dat) {
echo '<img src="' . $dat->images->standard_resolution->url . '" style="width:250px;height:200px;">';
}
}
?>

instagram access token generator :- https://instagram.pixelunion.net/