cpcdev
cpcdev

Reputation: 1214

Facebook PHP SDK v5 g2.4 Post to Fan Page

I am using Facebook PHP SDK v5 graph 2.4.

With the code below I can successfully post to my own page, but how can I set it to post to my fan page?

try {
    $response = $fb->post('/me/feed', $params, $access_token);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
    echo 'Graph returned an error: ' . $e->getMessage();
    exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
    echo 'Facebook SDK returned an error: ' . $e->getMessage();
    exit;
}

$graphNode = $response->getGraphNode();

I tried substituting my fan page id into it:

$response = $fb->post('/229107363768163/feed', $params, $access_token);

but I get the following error:

Graph returned an error: Unsupported post request.

EDIT: It seems I need a page access token?? Can someone please show me how?

Please help!

Upvotes: 0

Views: 180

Answers (1)

rashidkhan
rashidkhan

Reputation: 472

1.If you want to Post to a Fan's page then your App should be approved by Facebook's Team.

  1. The keyword "/me" doesn't represent just you. It represents every active or logged in user. If the user approves your app then you can post to their wall.

Upvotes: 1

Related Questions