简体   繁体   English

Facebook Javascript SDK

[英]Facebook Javascript SDK

是否可以使用FB.ui制作Facebook墙贴,但不向用户显示弹出对话框?

No, not with FB.ui . 不,不是FB.ui To post directly to the users wall without a dialogue you would have to use FB.api . 要在没有对话的情况下直接发布到用户墙上,您必须使用FB.api To do this the user will have to be logged in and have granted your app the publish_stream permission. 为此,用户必须登录并已为您的应用授予publish_stream权限。 The code example from the documentation: 文档中的代码示例:

var body = 'Reading JS SDK documentation';
FB.api('/me/feed', 'post', { message: body }, function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Post ID: ' + response.id);
  }
});

Be aware though that Facebook dislikes direct wall posting, and unless the content you are posting is a direct result of the user's interaction with the flow of your app, you run the risk of being flagged as spam and having your app suspended. 请注意,尽管Facebook不喜欢直接在墙上进行发布,并且除非您所发布的内容是用户与您的应用程序流进行交互的直接结果,否则冒着被标记为垃圾邮件和暂停应用程序的风险。 From the platform policy (section IV) : 根据平台政策(第四节)

.2. .2。 You must not pre-fill any of the fields associated with the following products, unless the user manually generated the content earlier in the workflow: Stream stories (user_message parameter for Facebook.streamPublish and FB.Connect.streamPublish, and message parameter for stream.publish), Photos (caption), Videos (description), Notes (title and content), Links (comment), and Jabber/XMPP. 除非用户在工作流程的前面手动生成了内容,否则不得预填充与以下产品关联的任何字段:流故事(Facebook.streamPublish和FB.Connect.streamPublish的user_message参数,以及stream的message参数。发布),照片(标题),视频(描述),便笺(标题和内容),链接(评论)和Jabber / XMPP。

.3. .3。 If a user grants you a publishing permission, you must still obtain consent from the user before taking any action on the user's behalf, such as publishing content or creating an event. 如果用户授予您发布权限,则在代表用户采取任何操作(例如发布内容或创建事件)之前,您仍必须征得用户的同意。

From personal experience, Facebook will insist on your app notifying the user in some way before taking any publish action. 根据个人经验,Facebook会坚持要求您的应用以某种方式通知用户,然后再执行任何发布操作。 This won't stop you putting an app live that contravenes their policies, but if their app monitoring team pick up on it they can and will suspend the app until you make the required changes. 这不会阻止您发布违反其政策的应用程序,但是如果他们的应用程序监视团队选择了该应用程序,他们可以并且将暂停该应用程序,直到您进行所需的更改为止。

Try the graph api ? 试试图API吗? Here's the relevant section: 这是相关的部分:

You can publish to the Facebook graph by issuing HTTP POST requests to the appropriate connection URLs, using an access token. 您可以使用访问令牌通过向适当的连接URL发出HTTP POST请求来发布到Facebook图。 For example, you can post a new wall post on Arjun's wall by issuing a POST request to https://graph.facebook.com/arjun/feed : 例如,您可以通过向https://graph.facebook.com/arjun/feed发出POST请求,在Arjun的墙上张贴新的墙上帖子:

 curl -F 'access_token=...' \\ -F 'message=Hello, Arjun. I like this new API.' \\ https://graph.facebook.com/arjun/feed 

Obviously, this isn't the JavaScript API, but it does the trick. 显然,这不是JavaScript API,但却可以解决问题。 I don't think it can be done without the popup directly through the JavaScript API. 我认为,如果没有直接通过JavaScript API弹出窗口,就无法完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM