0

I'm trying to make a post to FB page with images.

It looks like this:

First create image:

$res = Http::post(
        env("FB_API") .
            'my-page-id' .
            "/photos?access_token=" .
            'my-access-token',
        [
            "url" => 'https://cdn.filestackcontent.com/DAOSdaS9ed3GPsJlAmqw',
        ]
    );

Response:

"{"id":"52305359978858","post_id":"31457605812596_523305373312190"}" 

Then I make the actual post call:

    $id = json_decode($res->body())->id;

    $uri =
        env("FB_API") .
        'my-page-id' .
        "/feed?access_token=" .
        'my-access-token'.
        '&attached_media[0]={"media_fbid":"'.$id.'"}';


    $res = Http::post($uri, [
        'message' => "test"
    ]);

But I keep getting this error:

"{"error":{"message":"An unknown error has occurred.","type":"OAuthException","code":1,"fbtrace_id":"ARajcZtA7tWcd05G5V71pr"}}"

This is strange because when I post without image it's working.

The scopes my token has:

pages_read_engagement,
pages_manage_posts,
pages_show_list,
instagram_basic,
instagram_content_publish,
instagram_manage_comments
8

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy