AJAX和放大器; PHP:GET​​造成Flickr API键误差参数放大器、误差、参数、PHP

2023-09-10 21:34:05 作者:死若秋叶゛

我试图发送带有aFLickr API密钥的URL来获取结果对于一个给定的照片标签。阿贾克斯code应XML回到我的浏览器。然而,URL结构与参数似乎产生一个问题,我的设置:

I'm trying to send a URL with aFLickr API key to fetch results for a given photo tag. The Ajax code should return the XML to my browser. However the URL structure with parameters seems to cause a problem in my setup:

**the HTML file:**
...
url="api.flickr.com/services/rest/?method=flickr.photos.search&api_key=75564008a468bf8a284dc94bbd176dd8&tags=paris"

request.open("GET","xmlget.php?url=" + url + nocache, true)
...

**the 'xmlget.php' file:**
...
echo file_get_contents($_GET['url']);
...

错误: code =100味精=无效的API密钥(密钥格式无效)>

error: code="100" msg="Invalid API Key (Key has invalid format)">

链接工作正常,如果在地址栏中测试,所以必须有一个崩溃的地方当URL被处理。

the link works fine if tested in the adress bar so there must be a breakdown somewhere when the URL is processed.

我试图将其包装成连接codeURI ,但没有运气:(

i tried wrapping it into encodeURI but no luck :(

注:related帖子

推荐答案

您需要使用连接codeURIComponent 而不是连接codeURI 来实际获得该字符串连接codeD。

You need to use encodeURIComponent instead of encodeURI to actually get that string encoded.

我可以做2建议?

只是通过搜索参数xmlget.php并完成剩下的还有,即使这意味着必须通过一个服务类型,如果您使用的是一般 我不记得什么都一个Flickr API键可以让你,但它通常是一个坏事张贴任何所谓的公开的API密钥。除了这个问题,其包括粘它在该最终用户可以访问的JavaScript。
 
精彩推荐
图片推荐