已迁移到 Facebook Graph API - 应用程序现已损坏 - 无法发布到墙上
昨天我更改了应用程序设置并启用了“新数据权限”和“新 SDK”。
此后向用户墙发布消息的功能停止工作。在我的网站上,用户使用 facebook API(图)登录并能够在他们的墙上发布消息。
这是我的旧代码,运行良好:
function publish_with_permission(permission,action_links,attachment) { FB.ensureInit(function() { FB.Connect.requireSession(function(){ //check is user already granted for this permission or not FB.Facebook.apiClient.users_hasAppPermission(permission, function(result) { // prompt offline permission if (result == 0) { // show the facebook permission dialog FB.Connect.showPermissionDialog(permission, function(result){ if (!result) { FB.Connect.streamPublish('', attachment, action_links, null, "Post this:", jscallback); } else { // permission granted, post without facebook dialog FB.Connect.forceSessionRefresh(function() { FB.Connect.streamPublish('', attachment, action_links, null, "Post this:", jscallback,true); }); } }, true, null); } else { // permission already granted, post suddenly // without facebook dialog FB.Connect.streamPublish('', attachment, action_links, null, "Post this:", jscallback,true); } }); }); }); }
该函数只是挂起,没有任何反应。我在这个论坛上搜索并找到了这个 post
function fb_publish() { FB.ui( { method: 'stream.publish', message: 'Message here.', attachment: { name: 'Nom ici.', caption: 'Caption here.', description: ( 'description here' ), href: 'url here' }, action_links: [ { text: 'Code', href: 'action url here' } ], user_prompt_message: 'Personal message here' }, function(response) { if (response && response.post_id) { alert('Post was published.'); } else { alert('Post was not published.'); } } ); }
这个可行,但有两个问题 1) 即使当用户第一次使用图形 API 登录并且他们已授予发布到他们的墙的扩展权限时,此方法每次都会询问用户是否允许 - 前一个方法没有这样做。 2)此方法还允许用户添加他们的评论 - 我也不想要这个。
我想无缝地发布到墙上,而无需再次明确请求许可,因为他们之前已经授予了许可。
我正在使用 PHP - 任何提示将不胜感激 谢谢
Yesterday I changed the application settings and enabled "New Data Permissions" and "New SDKs".
After that the feature of posting message to the users wall stopped working. On my website, users login using facebook API (Graph) and are able to post messages on their wall.
This is my old code that was working fine:
function publish_with_permission(permission,action_links,attachment) { FB.ensureInit(function() { FB.Connect.requireSession(function(){ //check is user already granted for this permission or not FB.Facebook.apiClient.users_hasAppPermission(permission, function(result) { // prompt offline permission if (result == 0) { // show the facebook permission dialog FB.Connect.showPermissionDialog(permission, function(result){ if (!result) { FB.Connect.streamPublish('', attachment, action_links, null, "Post this:", jscallback); } else { // permission granted, post without facebook dialog FB.Connect.forceSessionRefresh(function() { FB.Connect.streamPublish('', attachment, action_links, null, "Post this:", jscallback,true); }); } }, true, null); } else { // permission already granted, post suddenly // without facebook dialog FB.Connect.streamPublish('', attachment, action_links, null, "Post this:", jscallback,true); } }); }); }); }
The function just hangs and nothing happens. I searched on this forum and found this post
function fb_publish() { FB.ui( { method: 'stream.publish', message: 'Message here.', attachment: { name: 'Nom ici.', caption: 'Caption here.', description: ( 'description here' ), href: 'url here' }, action_links: [ { text: 'Code', href: 'action url here' } ], user_prompt_message: 'Personal message here' }, function(response) { if (response && response.post_id) { alert('Post was published.'); } else { alert('Post was not published.'); } } ); }
This one works, but it has two problems
1) Even though when the user logs in first time using graph API and they have granted extended permissions to publish to their wall, this method will everytime ask the user whether to allow or not - The previous one did not do that.
2) This method also allows user to add their comments - I dont want this either.
I want to seamlessly publish to the wall without again explicitly asking for the permission as they have already granted it before.
I am using PHP - any tips will be appreciated
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想这就是你要找的。
预先获取权限。
和
然后使用 Graph API 而不是 Javascript SDK 发布到流。
(这在发布时根本不会涉及用户,并且将在您的 php 代码中的服务器端发生)
I think this is what you're looking for.
Take the permissions upfront.
And
then publish to stream using Graph API rather than Javascript SDK.
(this will not involve the user at all while publishing, and will happen on server side in your php code)
我无法找到使用 Javascript 的方法 - 所以我使用 php
希望它可以帮助别人
I could not figure out a way to do it using Javascript - so I used php instead
Hope it helps someone
尝试将此代码发布在墙上
此代码适用于我的应用程序。希望它也能解决您的问题。
try this code to post on wall
This code works on my app. hope it'll solve your problem too .