POST请求到Picasa API [英] POST request to Picasa API
问题描述
我心中已经是挣扎在Picasa中API POST。
这里是code:
I'v been struggling with POST on the Picasa API. Here's code:
$.ajax({
type: "POST",
url: 'https://picasaweb.google.com/data/feed/api/user/' + uid + '/albumid/' + album_id + '/photoid/' + photo_id,
crossDomain: true,
data: { content: content },
success: function() { alert("Success"); },
error: function() { alert('Failed!'); }
});
我已经通过检索获得一些信息没有问题。
I've already retrieved some information via GET without problems.
现在到了有趣的部分,当我尝试测试与谷歌服务出现此错误:
Now comes the fun part, when I try to test the service with Google this error occurs:
XMLHttpRequest cannot load
https://picasaweb.google.com/data/feed/api/user/userid/albumid/albumid/photoid/photoid?content=foo%bar.
Origin http://localhost:3000 is not allowed by
Access-Control-Allow-Origin
当我尝试在Firefox中的请求头的方法更改为选项
和地位是 204:无内容
。结果
另外,我试图改变数据类型
到 JSONP
但随后的HTTP方法更改 GET
并检索有关图像信息。
And when I try in Firefox the request header method is changed to OPTIONS
and status is 204: no content
.
Also, I've tried to change datatype
to jsonp
but then HTTP method changes to GET
and it retrieves information about the picture.
推荐答案
访问控制允许来源
来了,因为你正在一个Ajax调用到服务器,是不是与您当前的域。
阅读更多 rel=\"nofollow\">
Access-Control-Allow-Origin
is coming because your are making a ajax call to a server which is not same as your current domain.
Read more here
JSONP
将不利于为 POST
请求,因为你只能让 GET
与要求 JSONP
。
jsonp
will not help for POST
request because you can only make GET
request with jsonp
.
恕我直言,你应该尽量让从服务器端,而不是客户端脚本的POST请求。
IMHO you should try to make the POST request from server side instead of client side script.
这篇关于POST请求到Picasa API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!