AJAX和放大器; PHP:GET​​造成Flickr API键误差参数 [英] AJAX & PHP:GET parameters causing Flickr api key error

查看:108
本文介绍了AJAX和放大器; PHP:GET​​造成Flickr API键误差参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图发送带有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 :(

注:<一href="http://stackoverflow.com/questions/5359127/ajax-javascript-xml-adding-dom-elements-to-array-not-working">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。

这篇关于AJAX和放大器; PHP:GET​​造成Flickr API键误差参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆