0

我想将 URL 作为附件发布到朋友墙:

var attachment={'name':'favor','href':'http://128.196.239.71/movie.php?mid=<?php echo  $_GET['mid']; ?>'};
                                         Facebook.streamPublish('',attachment,null,friends[i],comment,callback);

执行上述操作会给我一个未定义的 Facebook,我应该怎么做才能解决这个问题?

我是否需要设置特殊权限才能对此邮件的发件人执行此操作?

4

1 回答 1

2

You do need the stream.publish permission in order to use the stream.publish method or the equivalent graph API call.

You can check that the user has already granted this permission with something like this:

FB.getLoginStatus(function(response) { if (response.perms) { /* check perms */ } })

You can request the permission with something like this:

FB.login(function(response) { /* check perms */ }, {scope: 'publish_stream'})

Then in the response you can check to see if it was actually granted, then you should be able to do stream publish calls.

However, I don't recognize the format of your call "Facebook.streamPublish". I think the new API requires you to do a call more like

FB.api({method: 'stream.publish', message: 'hello'}, function(response) {})

Alternatively to all this, you can use the dialogs API to create a post and show it to the user, and have them approve it or disapprove it. This does not require the stream.publish permission. Something like this (the example given in the FB.ui API docs):

 FB.ui(
   {
     method: 'feed',
     name: 'Facebook Dialogs',
     link: 'http://developers.facebook.com/docs/reference/dialogs/',
     picture: 'http://fbrell.com/f8.jpg',
     caption: 'Reference Documentation',
     description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
     message: 'Facebook Dialogs are easy!'
   },
   function(response) {
     if (response && response.post_id) {
       alert('Post was published.');
     } else {
       alert('Post was not published.');
     }
   }
 );

At the rate Facebook changes, I hope some of this information is still accurate by the time you read it (or even accurate to begin with).

于 2011-05-01T07:16:06.667 回答