POST request to Picasa API

若如初见. 提交于 2019-12-02 10:23:46

问题


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

.

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.


回答1:


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 will not help for POST request because you can only make GET request with jsonp.

IMHO you should try to make the POST request from server side instead of client side script.



来源:https://stackoverflow.com/questions/13514355/post-request-to-picasa-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!