artdarek / oauth-4-laravel

OAuth Service Provider for Laravel 4
684 stars 217 forks source link

How to post to users wall on facebook getting "Failed to request resource."? #131

Closed Haseeb90 closed 9 years ago

Haseeb90 commented 9 years ago

I got the access_token and I have gotten all the permissions required but can't figure out how to post to the users wall

Haseeb90 commented 9 years ago

I have the following code $postMessage = json_decode( $fb->request('POST', "/me/feed?access_token={$_SESSION['facebook_access_token']}", array ( 'message' => 'This is a test message' ) ), true ); return $postMessage;

but im getting the following error {"error":{"type":"OAuth\Common\Http\Exception\TokenResponseException","message":"Failed to request resource."

Haseeb90 commented 9 years ago

Where as when I do this $user = json_decode( $fb->request( "/me?access_token={$_SESSION['facebook_access_token']}" ), true );

it works fine

Haseeb90 commented 9 years ago

I found the mistake ... The call is supposed to be as follows

$postMessage = json_decode( $fb->request (

            "/me/feed?access_token={$_SESSION['facebook_access_token']}",
            'POST', 
            array (
                'message' => 'This is a test message'
            )
        ), 
    true );

The route is supposed to be first and then the POST.