Skip to content

Instantly share code, notes, and snippets.

@samuelsimoes
Created June 24, 2012 00:54
Show Gist options
  • Save samuelsimoes/2980808 to your computer and use it in GitHub Desktop.
Save samuelsimoes/2980808 to your computer and use it in GitHub Desktop.
Trabalhar com o JSON da API do Flickr com o PHP
<?php
$curl = curl_init();
// Atente para o nojsoncallback=1
curl_setopt($curl, CURLOPT_URL, 'http://api.flickr.com/services/feeds/photos_public.gne?format=json&id=8418630@N03&nojsoncallback=1');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$resposta = curl_exec($curl);
// Corrige o problema do JSON inválido quando há uma aspa simples na legenda da foto
preg_match("/\\\'/", $resposta, $content);
$resposta = preg_replace("/\\\'/", "'", $resposta);
$resposta = json_decode($resposta);
print_r($resposta);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment