Reputation: 23
<?php
$userid = "USER_ID";
$accessToken = "EXAMPLE_TOKEN";
$url = "https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result);
foreach ($result->data as $post)
{
echo '<p> <a class="fancybox" href="'.$post->images->standard_resolution->url.'" data-fancybox-group="gallery" title="'.$post->caption->text.'"><img src="'.$post->images->thumbnail->url.'" alt="SOME TEXT HERE"></p>';
}
?>
id like to use this working code so i can populate a div but its not working on wordpress.
Upvotes: 0
Views: 2619
Reputation: 68526
Since you are calling a HTTPs
URL , you need to enable this parameter..
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
By setting this paramater to FALSE prevents cURL from verifying the peer's certificate
Upvotes: 1