Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Facebook Graph Sdk

Facebook Graph Sdk Laravel Package

martin1982/facebook-graph-sdk

PHP 7.4+ Facebook Graph SDK (v7) for accessing the Facebook Platform. Install via Composer, initialize with app ID/secret, and make Graph API requests with built-in helpers for login flows and access tokens. Includes docs and PHPUnit tests.

View on GitHub
Deep Wiki
Context7

The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login. https://developers.facebook.com/docs/php

Frequently asked questions about Facebook Graph Sdk
How do I integrate this Facebook Graph SDK into a Laravel app for user authentication?
Use the SDK’s built-in helpers like `RedirectLoginHelper` for OAuth flows. Initialize the client with your `app_id`, `app_secret`, and `default_graph_version` (e.g., `v10.0`), then handle the callback in Laravel’s routes. Store tokens manually in Laravel’s session or database, as the SDK lacks native Laravel auth integration.
Does this package support Laravel’s Sanctum or Passport for token storage?
No, this SDK doesn’t integrate directly with Sanctum or Passport. You’ll need to manually store access tokens in Laravel’s session, cache, or database. Pair it with `laravel/sanctum` for seamless token management if needed.
Will this work with Laravel 10 and PHP 8.1+?
The SDK requires PHP 7.4+, but Laravel 10+ uses PHP 8.1+. While it may work, you’ll miss PHP 8.x optimizations like named arguments. Test thoroughly, especially for type safety and performance.
How do I handle Facebook API errors in Laravel’s exception handler?
Catch `FacebookResponseException` and `FacebookSDKException` in your Laravel routes or middleware. Log errors with `Log::error()` and convert them to Laravel’s `HttpResponse` for consistent error handling across your app.
Can I use this SDK for async Facebook API calls in Laravel queues?
No, the SDK blocks execution synchronously. For async calls, wrap API requests in Laravel Queues using Guzzle’s promises or the `guzzlehttp/promises` package to avoid blocking workers.
What’s the best way to manage Facebook access tokens in production?
Store tokens securely in Laravel’s encrypted database or cache (e.g., Redis). Avoid session storage for long-lived tokens. Use middleware to validate tokens on protected routes and implement token refresh logic manually.
Does this SDK support Facebook’s Marketing API or Lead Ads?
Yes, the SDK supports the full Graph API, including Marketing API and Lead Ads, as long as you use `default_graph_version=v10.0` or later. Ensure your Facebook app has the required permissions.
How do I test this package in Laravel without hitting rate limits?
Use Facebook’s test credentials (configured in `tests/FacebookTestCredentials.php`) to run PHPUnit tests locally. Mock API responses in Laravel’s `Http` tests to avoid live requests and rate limits.
What are the alternatives to this SDK for Laravel apps?
Consider the official `facebook/graph-sdk` (PHP 8.x compatible) or `spatie/laravel-facebook` for tighter Laravel integration. The official SDK is more actively maintained but lacks Laravel-specific helpers.
How do I handle CORS or CSRF when using the JavaScript helper in Laravel?
The SDK’s JavaScript helper requires proper CORS setup on your Laravel app. Use Laravel’s `VerifyCsrfToken` middleware and ensure your Facebook app’s domain matches your Laravel app’s domain in Facebook Developer settings.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
babenkoivan/elastic-client
innmind/static-analysis
innmind/coding-standard
datacore/hub-sdk
alengo/sulu-http-cache-bundle
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard
visualbuilder/filament-lottie
servicioslineaonce/starter-kit
atomcoder/laravel-reorderable
irajul/filament-shadcn-theme
agtp/agtp-php
agtp/mod-php
centraldesktop/protobuf-php