views:

2149

answers:

4

Hi all,

I've been implementing Facebook Connect into a site and am using both the PHP API, to allow me to automatically post data to a user's wall, as well as the JS API, for manual posting, permissions dialogs, etc. When the user uses the manual method it works 100%...the popups are displayed correctly, and the data gets posted to their wall properly. However, when I try to use the PHP API I am getting inconsistencies.

When I try posting automatically using the PHP API using one account it works perfect, every time. But for some other accounts it never works, always returning "Permissions error." The error code is 200, and I've checked the Facebook API documentation and it's pretty vague, saying only "Permissions error. The application does not have permission to perform this action." But that's not true, since it works on some accounts and doesn't work on others.

First, I've made sure that the users in question have enabled the extended permission "publish_stream" and that the manual method using the JS API works, so it doesn't seem to be a problem with those specific permissions. There are no apparent differences between the Facebook accounts I've used.

So my question is has anyone run into this problem and found a solution to it? Is there some sort of other permission setting that users must enable for this to work? I've been searching Google and these forums but have not found any solution.

The request I am sending is: (Note: The content/image url/link url are not the actual data I use)

$attachment = array(
    'caption'    => '{*actor*} commented on <title> "<comment>"',
    'media'    => array(
        array(
            'type'    => 'image',
            'src'    => 'http://www.test.com/image.jpg',
            'href'    => 'http://www.test.com'
        )
    )
);
$Facebook->api_client->stream_publish('', $attachment);

Thanks, Sarah

A: 

Be careful that you cannot make cross-website javascript request.

So if your code is not started from the www.test.com website, it will not work.

You should probably redirect people in test.com to www.test.com, or use $_SERVER['SERVER_NAME'] to be sure to use the good domain name.

Natim
That's not an issue. I have been testing using the same exact procedure, URLs, everything. The only inconsistency is the Facebook user account that is being used.
Sarah
A: 

You need to ask for the prompt_permissions tag before you can publish to the stream not using javascript. If you use javascript that requires user interaction, you don't have to prompt for stream.publish permissions. Make sure you request the right permissions. I'm guessing that the permissions didn't go through for all users... or it requires a different permission set.

CodeJoust
If that were the case, it should be consistent for every user, right? But the main reason I find this issue so hard to debug is that it's not consistent. It works for some users and doesn't for others...doing the same exact procedure.I've already made sure the users in question have all the necessary permissions, since if the automatic method doesn't work I automatically pop up the JS window and do it manually. Once the popup pops up and they post it to their wall, it should have all the necessary permissions, but it continues to fail with PHP even after posting it successfully using JS.
Sarah
A: 

the following article was very helpful for me and did the trick

http://wiki.developers.facebook.com/index.php/Extended%5Fpermissions

Edwinistrator
I have already been through that page, and it was what I used to initially check which extended permission I needed to enable to get it to work. The extended permission that it should be requiring, and that is enabled for the users in question, is "publish_stream," yet even after verifying that the user has it enabled, it still gives me the Permissions Error response when executing it from the PHP API.
Sarah
A: 

the answer is really quite simple log in facebook on pc go to account the app settings on the right side is a drop down box with facebook for android just edit setting to allow permission and your all set worked perfect for me

dave