开发者

Php file tries to download instead of execute code

I have the following in my .php file. Just trying a simple search on Flickr. When I visit this .php page in my browser a download dialog pop up. I was expecting to see the json echoed out on the page. I am using WAMP and have url fopen() enabled.If I comment out this code and echo out "WORKING" it does work just fine.

$api_key = "MYKEYHERE";
$tag = 'flower';
$perPage = 25;
$url = 'http://api.flickr.com/services/rest/?method=flickr.photos.search';
$url.= '&api_key='.$api_key;
$url.= '&tags='.$tag;
$url.= '&per_page='.开发者_如何学运维$perPage;
$url.= '&format=json';
$url.= '&nojsoncallback=1';
header('Content-Type:text/json;');
echo file_get_contents($url);

Seems something is wrong somewhere?


See this previous question that I answered about the same issue:

How can I prevent user-agents from presenting a download window for unrecognized mime types?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜