facebook-poster icon indicating copy to clipboard operation
facebook-poster copied to clipboard

Required "app_id" key (FACEBOOK_APP_ID)

Open Bjornftw opened this issue 4 years ago • 9 comments

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'),
],

Bjornftw avatar May 25 '20 18:05 Bjornftw

Have you cached your config or anything like that? Can you dump config('services.facebook_poster') and verify everything is there?

dwightwatson avatar May 25 '20 23:05 dwightwatson

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 ▶"
]

KalimeroMK avatar Jul 11 '20 23:07 KalimeroMK

How to fix it not just close the ticket tray PHP artisan config:cache; config:clear

KalimeroMK avatar Jul 13 '20 05:07 KalimeroMK

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.

dwightwatson avatar Jul 13 '20 05:07 dwightwatson

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.

dwightwatson avatar Jul 13 '20 05:07 dwightwatson

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());
}

}`

KalimeroMK avatar Jul 13 '20 05:07 KalimeroMK

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?

dwightwatson avatar Jul 13 '20 05:07 dwightwatson

let my try :) on new install

KalimeroMK avatar Jul 13 '20 05:07 KalimeroMK

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,
]);

KalimeroMK avatar Oct 14 '20 16:10 KalimeroMK