I am getting data from the Flickr API with a middle-man file (to avoid crossdomain problems):
<?php
header( Cache-Control: no-cache, must-revalidate );
header( Expires: Mon, 26 Jul 1997 05:00:00 GMT );
header( Content-type: application/json );
die(json_encode( file_get_contents($_REQUEST[ url ]) ) );
?>
This file is fetched by javascript:
//Flickr
var myurl = encodeURIComponent( http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=1408bff5f72a4b84b924d13e8562b6a2&photoset_id=77649470@N03&photoset_id=72157629903184261&format=json );
$.getJSON( "middle.php?url=" + myurl, function(data){
console.log(typeof data);
});
但是,这只是ole。 记录显示,结果是一种“扼杀”,而不是“焦耳”。 Ive试图将其改装成一个有:
jQuery.parseJSON(data)
but the console gave me this error:
Uncaught SyntaxError: Unexpected token j
This is the string:
jsonFlickrApi({"photoset":{"id":"72157629903184261", "primary":"7115173307", "owner":"77649470@N03", "ownername":"wedocommunication", "photo":[{"id":"7115173331", "secret":"24900ff306", "server":"5447", "farm":6, "title":"Lounge", "isprimary":"0"}, {"id":"7115173307", "secret":"3435f9a983", "server":"7256", "farm":8, "title":"Hofansicht", "isprimary":"1"}, {"id":"7115173379", "secret":"7747e50597", "server":"7278", "farm":8, "title":"Konfi", "isprimary":"0"}, {"id":"6969093048", "secret":"d4389bc0e4", "server":"7055", "farm":8, "title":"Lounge", "isprimary":"0"}, {"id":"6969093086", "secret":"8e7263005b", "server":"5152", "farm":6, "title":"Eingangsbereich", "isprimary":"0"}], "page":1, "per_page":500, "perpage":500, "pages":1, "total":"5"}, "stat":"ok"})
我可以做些什么来把扼杀变成物体?