I'm trying to make a Laravel task that will publish a picture each week on my page.

Here's my code:

public function postToFacebook($message, $imageUrl): array|string{         try {             $response = $this->fb->post('/me/feed', [                 'message' => $message,                 'link' => "https://google.fr",             ], env('FACEBOOK_ACCESS_TOKEN'));             return $response->getDecodedBody();         } catch(\Facebook\Exceptions\FacebookResponseException $e) {             return 'Graph returned an error: ' . $e->getMessage();         } catch(\Facebook\Exceptions\FacebookSDKException $e) {             return 'Facebook SDK returned an error: ' . $e->getMessage();         }     } 

I already checked content of $message and env('FACEBOOK_ACCESS_TOKEN'), everything is OK.

But I always get :

Undefined array key 1 

on post() method.

I am using "facebook/graph-sdk" package.

Is it mandatory to have a FB app up and running ? Mine is not published, but it is asking me a bunch of things, like Business verification that is not very relevant, as I do it for myself...

Do you have any idea how should I fix the issue ?

Tag:laravel, facebook-graph-api

Add a new comment.