Cyclone
Cyclone

Reputation: 18285

Publish to facebook stream in PHP

I've been trying to accomplish stream publishing with this JS method:

function streamPublish(name, description, hrefTitle, hrefLink, userPrompt){
    FB.ui(
    {
        method: 'stream.publish',
        message: '',
        attachment: {
            name: name,
            caption: '',
            description: (description),
            href: hrefLink
        },
        action_links: [
            { text: hrefTitle, href: hrefLink }
        ],
        user_prompt_message: userPrompt
    },
    function(response) {

    });
}

but it never works on Internet Explorer. How can I achieve this same result (or whatever result would be considered "standard" for a facebook application posting to a user's stream) in PHP? The facebook API documentation is poor and doesn't include many code examples.

Upvotes: 2

Views: 5908

Answers (2)

Kostas
Kostas

Reputation: 9

As of June 3rd, the API call should include the access_token. So be careful to include 'access_token' => ACCESS_TOKEN, in the $attachment array.

@med: Med, have you checked if your image is publicly accessible (i.e. not served by your machine in an intranet)?. It seems like the image can't be accessed.

Upvotes: 1

Ailef
Ailef

Reputation: 7906

Use the api function from the Facebook PHP SDK like this:

$facebook->api('/$USER_ID/feed', 'POST', $attachment);

Where $attachment is an object built this way:

$attachment = array(
'message' => MESSAGE,
            'name' => TITLE,
            'link' => URL,
            'description' => DESC,
'picture'=> IMAGE,
    );

You can check other kind of params to pass with the attachment on the facebook developers website

Upvotes: 1

Related Questions