Wednesday 15 September 2010

function - PHP Curl Pagination: A faster way? -



function - PHP Curl Pagination: A faster way? -

i wanting retrieve media user has liked instagram api. instagram returns around lastly 300 liked media next endpoint:

get /users/self/media/liked

each phone call returns around 30 results, have approximately 10 pages scan through curl function takes 10 seconds.

is there faster way this? know curl_multi allows fire mu

public function fetchlikes() { $url = 'https://api.instagram.com/v1/users/self/media/liked?count=100&access_token=' . $access_token; while (isset($url) && $url != '') { $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_ssl_verifypeer, false); $jsondata = curl_exec($ch); curl_close($ch); $response = json_decode($jsondata); foreach ($response->data $post) { echo $post->user->username . "<br>"; } $url = $response->pagination->next_url; } }

php function api curl instagram

No comments:

Post a Comment