Bonjour,
avec YQL, je cherche à afficher une photo suivant la ville.
Mon problème est que je n'arrive pas à afficher la la photo.
Le résultat est jSon.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
	"query":
	{
		"count":1,"created":"2012-07-19T20:25:48Z","lang":"en-US","diagnostics":
		{
			"publiclyCallable":"true","url":
			{"execution-start-time":"23","execution-stop-time":"189","execution-time":"166",
				"content":"http://api.flickr.com/services/rest/?method=flickr.photos.search&text=Austin&page=1&per_page=10"
			},
			"user-time":"190","service-time":"166","build-version":"28958"
		},
		"results":
		{
			"photo":
			{
				"farm":"9","id":"7605431754","isfamily":"0","isfriend":"0","ispublic":"1","owner":"36986152@N06",
				"secret":"a8f8c920e8","server":"8290","title":"Spc. Austin Okorn"
			}
		}
	}
}
PHP :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php 
// requete YQL
//select * from flickr.photos.search where text="Austin" and api_key="aa56686b0423ae4561be1d7beab83ec6" limit 1
 
 
//http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20flickr.photos.search%20where%20text%3D%22Austin%22%20and%20api_key%3D%22aa56686b0423ae4561be1d7beab83ec6%22%20limit%201&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys
$c=curl_init("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20flickr.photos.search%20where%20text%3D%22Austin%22%20and%20api_key%3D%22aa56686b0423ae4561be1d7beab83ec6%22%20limit%201&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($c);
curl_close($c);
$res=json_decode($data);
 
echo '<pre>';
var_dump($data);
echo '</pre>';
?>
<img alt="ddddd" src="7605431754">
Peut-être y a t-il une autre techno pour faire ceci ?
Merci