Created
June 24, 2012 00:54
-
-
Save samuelsimoes/2980808 to your computer and use it in GitHub Desktop.
Trabalhar com o JSON da API do Flickr com o PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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