2014-11-05 1 views
0

에 의한 응답을하지 마십시오 내 코드입니다 :인스 타 그램의 API 여기

<?php 

    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/search?q=majoe_47&access_token=[hidden]"); 
    var_dump($result); 
    $result = json_decode($result); 
    foreach ($result->data as $post) { 
    // Do something with this data. 

    } 
?> 

출력 :

{"meta":{"code":200},"data":[{"username":"majoe_47","bio":"Breiter als der T\u00fcrsteher","website":"http:\/\/www.facebook.com\/majoeduisburg","profile_picture":"http:\/\/photos-a.ak.instagram.com\/hphotos-ak-xfa1\/10584773_1460870534165160_603268483_a.jpg","full_name":"Majoe","id":"256143447"} [..more code ..]}]}

이유 : 직접 URL을 bool(false)

출력 나는 어떤 반응도 얻지 못했습니까? :/

+0

액세스 토큰을 제거해야합니다. 그냥 당신을 위해 그것을했다;) –

답변

1
function fetchData($url) 
    { 
     $channel = curl_init(); 
     curl_setopt($channel, CURLOPT_URL, $url); 
     curl_setopt($channel, CURLOPT_RETURNTRANSFER, true); 
     curl_setopt($channel, CURLOPT_CONNECTTIMEOUT, 10); 
     curl_setopt($channel, CURLOPT_TIMEOUT, 10); 
     curl_setopt($channel, CURLOPT_ENCODING , "gzip"); 
     curl_setopt($channel, CURLOPT_VERBOSE, true); 
     curl_setopt($channel, CURLOPT_FOLLOWLOCATION, true); 
     curl_setopt($channel, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); 
     curl_setopt($channel, CURLOPT_SSL_VERIFYPEER, FALSE);  //add this 
     curl_setopt($channel, CURLOPT_SSL_VERIFYHOST, FALSE);  // and this line to support https 
     $output = curl_exec($channel); 
     curl_close($channel); 
     return $output; 
    } 
+0

그가 게시 한 기능에 문제가 있습니까? 그것은 완벽하게 잘 작동합니다. –

+0

대단히 감사합니다. D – mistermm

+0

@ mistermm 그게 효과가 있었습니까? –

관련 문제