Facebook图形API-为什么使用异步Ajax文件上传我无法获得带照片的ID响应? [英] Facebook graph api - why using async ajax file upload i cannot get the photo id response?

查看:95
本文介绍了Facebook图形API-为什么使用异步Ajax文件上传我无法获得带照片的ID响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iframe技术将照片上传到Facebook图形API. 我正在使用这种技术: http://www.openjs.com/articles/ajax/ajax_file_upload/response_data.php .

Im using the iframe techinique to upload a photo to the facebook graph api. im using this technique: http://www.openjs.com/articles/ajax/ajax_file_upload/response_data.php.

照片成功上传.但是我需要在iframe上读取它给我的响应,但是我无法做到. 我尝试了所有我知道的技术,纯JavaScript和jQuery hack ..但没有任何效果...

The photo gets uploaded sucessfully. But i NEED to read the response it gives to me on my iframe, but im not being able to do it. I tried every technique i know, pure javascript and jquery hacks.. but nothing works...

响应的格式如下(我可以在chrome js控制台上看到它):

the format of the response is the following (i can see this on chrome js console ):

{
   "id": "111346062333977",
   "post_id": "100003757518505_111258412342742"
}

那是什么格式?我该怎么读?它不在DOM上,它不在身体上,它不在乎!!!!

what is that format? how can i read it? its not on the DOM, its not on the body, its nowere!!!!

推荐答案

如果我了解您的问题,那么您会遇到

If I understand your problem then you came across the Same origin policy since you post the form into an iframe, and the action of the form is to another domain, different than yours (the one in which the main page is loaded from).

因此,您在iframe中获得的响应无法传递到父页面,因为它们不共享同一域,并且浏览器阻止了通信.

Because of that, the response you get in the iframe can not be then passed to the parent page since they don't share the same domain and the browser blocks the communication.

正如@JuicyScripter所写的那样,您可能要考虑从服务器端发布图像,这将使事情变得更简单. 如果您不想这么快就放弃客户端解决方案,建议您检查以下线程:

As @JuicyScripter wrote you might want to think about posting the image from the server side which will make things simpler. If how ever you don't want to give up on the client side solution so quickly, I suggest you check this thread: Facebook Graph API - upload photo using JavaScript

这篇关于Facebook图形API-为什么使用异步Ajax文件上传我无法获得带照片的ID响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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