facebook-poster
facebook-poster copied to clipboard
Required "app_id" key (FACEBOOK_APP_ID)
Hi,
I've followed every step but I can't fix this problem.
Required "app_id" key not supplied in config and could not find fallback environment variable "FACEBOOK_APP_ID"
My .env
FACEBOOK_APP_ID=my_app_id
FACEBOOK_APP_SECRET=my_app_secret
FACEBOOK_ACCESS_TOKEN=my_access_token
My config/services.php
'facebook_poster' => [
'app_id' => env('FACEBOOK_APP_ID'),
'app_secret' => env('FACEBOOK_APP_SECRET'),
'access_token' => env('FACEBOOK_ACCESS_TOKEN'),
],
Have you cached your config or anything like that? Can you dump config('services.facebook_poster')
and verify everything is there?
The same problem on my end and on a dd(config('services.facebook_poster')) return
^ array:3 [▼
"app_id" => "447881111111111"
"app_secret" => "447886111111111|JOf-XpjhoVj6PoX8iFkY_1ym2bY"
"access_token" => "EAAGXWaqI5dgBADFVPVPcXH60sNruOPyG6xPefTcOpBjTt3GlSUj8eM27pClYgrZCJunhWF4FwIfodiBJHsB5ywyApric2gcH4mPlBh4tygcYOd8oGH5wJ8ZAKKktK61UDXS2H8ZBO5eduKv2ijCko3hXffKPh0Z ▶"
]
but on dd($config) in vendor/facebook/graph-sdk/src/Facebook/Facebook.php return
^ array:9 [▼
"app_id" => null
"app_secret" => null
"default_graph_version" => "v2.10"
"enable_beta_mode" => false
"http_client_handler" => null
"persistent_data_handler" => null
"pseudo_random_string_generator" => null
"url_detection_handler" => null
"default_access_token" => "EAAGXWaqI5dgBADFVPVPcXH60sNruOPyG6xPefTcOpBjTt3GlSUj8eM27pClYgrZCJunhWF4FwIfodiBJHsB5ywyApric2gcH4mPlBh4tygcYOd8oGH5wJ8ZAKKktK61UDXS2H8ZBO5eduKv2ijCko3hXffKPh0Z ▶"
]
How to fix it not just close the ticket tray PHP artisan config:cache; config:clear
I don't think there's enough information here to go off.
What version of the package are you using? Are you trying to use Facebook directly, instead of through the channel?
We bind the Facebook configuration to the service provider - see https://github.com/laravel-notification-channels/facebook-poster/blob/master/src/FacebookPosterServiceProvider.php. If someone can provide a blank app that demonstrates this working I'll be happy to take a look, otherwise please review and see if you can find the issue.
For reference, I am running the current version (3.0.0) with Laravel 7.18 and it is working - so there is something else going on here.
I am running the current version (3.0.0) with Laravel 7.19 as well and use notification to run the package here is my code `<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use NotificationChannels\FacebookPoster\FacebookPosterChannel; use NotificationChannels\FacebookPoster\FacebookPosterPost;
class ArticlePublished extends Notification { use Queueable;
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [FacebookPosterChannel::class];
}
/**
* @param $post
* @return FacebookPosterPost
*/
public function toFacebookPoster($post)
{
return with(new FacebookPosterPost($post->title))
->withLink($post->getLink());
}
}`
There's still not enough information here.
Do you have something in your app that would be interfering with how this package interacts with Facebook? Are you able to replicate the broken behaviour in a fresh Laravel app with no other changes?
let my try :) on new install
fix the problem for me jus edit facebook.php in vendor :)
$config = array_merge([
'app_id' => getenv(static::APP_ID_ENV_NAME),
'app_secret' => getenv(static::APP_SECRET_ENV_NAME),
'default_graph_version' => static::DEFAULT_GRAPH_VERSION,
'enable_beta_mode' => false,
'http_client_handler' => null,
'persistent_data_handler' => null,
'pseudo_random_string_generator' => null,
'url_detection_handler' => null,
], $config);
If I switch the parameters for the array_merge call, it seems to work:
$config = array_merge($config, [
'app_id' => getenv(static::APP_ID_ENV_NAME),
'app_secret' => getenv(static::APP_SECRET_ENV_NAME),
'default_graph_version' => static::DEFAULT_GRAPH_VERSION,
'enable_beta_mode' => false,
'http_client_handler' => null,
'persistent_data_handler' => null,
'pseudo_random_string_generator' => null,
'url_detection_handler' => null,
]);