SammyK / LaravelFacebookSdk

Fully unit tested Facebook SDK v5 integration for Laravel & Lumen
MIT License
693 stars 201 forks source link

FacebookSdK working fine on localhost, NOT on server #190

Open michielalbracht opened 7 years ago

michielalbracht commented 7 years ago

Dear all,

SammyK/FacbeookSDK Is working fine as part of a command. But when I upload it to the server it gives the following error when the php artisan command is entered:

[Illuminate\Contracts\Container\BindingResolutionException]
Unresolvable dependency resolving [Parameter #1 [ <required> $url ]] in class SammyK\LaravelFacebookSdk\LaravelFacebookSdk

My code looks like this:

namespace App\Console\Components\Facebook;

use Illuminate\Console\Command;
use App\Events\Facebook\FacebookFetched;
use Illuminate\Support\Facades\App;
use SammyK;

class FetchFacebook extends Command
{
    protected $signature = 'site:fetch-fb';
    protected $description = 'Fetch Facebook Data';

    public function handle(SammyK\LaravelFacebookSdk\LaravelFacebookSdk $fb)
    {
        $token = [[my_token]];
        $fb->setDefaultAccessToken($token);
        try {
            $response = $fb->get((string) '[[ my request ]]');
        } catch(\Facebook\Exceptions\FacebookSDKException $e) {
            dd($e->getMessage());
            $this->info($e->getMessage());
        }
        $node = $response->getGraphNode();
        $this->info('likes: ' . $node['fan_count']);

        event(new FacebookFetched(array(
            'likes' => $node->getField('fan_count'),
        )));

    }

}

Can you help me please?