[英]How can I redirect after Facebook.streamPublish() has completed?
I have an application which will post a message on a friends wall using the Facebook.streamPublish() method, and this works perfectly. 我有一个应用程序,该应用程序将使用Facebook.streamPublish()方法在朋友墙上发布一条消息,并且此方法非常有效。 However, I want to also be able to save details about this post in my database.
但是,我还希望能够将有关此帖子的详细信息保存在我的数据库中。
All the information that needs to be stored is placed into hidden form fields and are all in place once the message has been sent, so I figure that all I need to do is redirect to a php file which will take this information, save it into the database and then redirect back to the main page. 所有需要存储的信息都被放置在隐藏的表单字段中,并且在消息发送后都就位了,因此我认为我所要做的就是重定向到一个php文件,该文件将接收此信息并将其保存到数据库,然后重定向回主页。
The streamPublish call is: streamPublish调用为:
Facebook.streamPublish(\'\', attachment, null, params.ids[curFriend]);
which I can follow with form.submit() which will cause the redirect to happen, but this submit() function gets called instantly, and doesn't wait for the streamPublish() popup to load, be used, and the action to be completed. 我可以使用form.submit()跟随它,这将导致重定向发生,但是此commit()函数被立即调用,并且不等待streamPublish()弹出窗口加载,使用和执行操作完成。 How can I make my form.submit() not be called until the user has hit the 'publish' button in the popup which occurs?
在用户点击弹出式窗口中的“发布”按钮之前,如何才能不调用form.submit()?
I've not used the streampublish() function or the FB API, but I can guarantee that this is because the streampublish is handled by an ajax call, which is thus handled separately from the normal JS code chronology. 我没有使用过streampublish()函数或FB API,但是我可以保证这是因为流发布是由ajax调用处理的,因此与正常的JS代码时间顺序分开处理。 So any code that should be executed when the ajax has reached a specific state needs to be added to the ajax statehandler, which the FB API may or may not give you access to.
因此,需要在ajax达到特定状态时执行的任何代码都需要添加到ajax状态处理程序中,FB API可能会也可能不会允许您访问。
StreamPublish also takes an optional callback function - http://developers.facebook.com/docs/?u=facebook.jslib.FB.Connect.streamPublish . StreamPublish也有一个可选的回调函数- http://developers.facebook.com/docs/?u=facebook.jslib.FB.Connect.streamPublish 。 Try setting your submit() function as the callback and it should get called once the user cancels the dialog or publishes it
尝试将您的commit()函数设置为回调函数,一旦用户取消对话框或发布对话框,该函数便会被调用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.