Why is my instagram api fetching data returning false instead of a json object?

I’m trying to use the instagram api on a wordpress page. Given the following function to get the data, would anyone please point me why is my var_dump($results) return boolean false???

function fetchData($url){
    $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); 
    return $result;
}


$result = fetchData("https://api.instagram.com/v1/users/{{userId}}/media/recent/?access_token={{accessToken}}&count=20");

var_dump($result);

note: {{userId}} & {{accessToken}} are placeholders. On my code Im using the real id and token instead.

Related posts

Leave a Reply

1 comment