Download the PHP package horde/service_facebook without Composer

On this page you can find all versions of the php package horde/service_facebook. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package service_facebook

horde/service_facebook

A modern PSR-4 client for Facebook's Graph API. Targets Graph v25 for now but is ready to actively support for a rolling window of prior versions once graph v26 is out. Integrates with horde/oauth for OAuth2/OIDC flows and horde/jwt for id_token verification.

Status: Partial

The legacy PSR-0 tree under lib/Horde/Service/Facebook/ targets Facebook's REST API (retired 2020) and FQL (retired 2016) and does not work against modern Facebook.

The new PSR-4 tree under src/ is the supported surface. New and updated code should use Horde\Service\Facebook\FacebookApiClient The legacy Horde_Service_Facebook classes are kept around to prevent code breaking on "unknown class", i.e. when it shipped the old client as a side concern and didn't really exercise facebook REST API.

Installation

Requires PHP 8.1+. The library is strict-PSR at runtime. Bring your own PSR-18 client (any conforming implementation. horde/http, Guzzle, Symfony HttpClient). Bring your own PSR-17 request and stream factories. The Facebook client wires everything through them.

Batteries-included wiring with horde/http:

Quick Start

Fetch the current user's profile:

Version Pinning

The default version comes from GraphApiVersion::default() (currently v25.0). To pin to an older supported version:

withVersion() returns a new immutable client. The original client remains pinned to its previous version. You can hold two client instances side by side without interference.

Supported versions are exposed as enum cases:

Note: The older APIs aren't really supported - This feature is designing against a foreaseeable shift on facebook side to V26 or V27 while still supporting V25 for a reasonable time.

Attempting to pass a version the library doesn't ship is a compile-time error. You cannot construct an unknown enum case. Whether Meta still accepts your pinned version on the wire is Meta's business. If they reject the request you get a GraphErrorException like any other server error.

See doc/VERSIONING.md for how new Facebook versions land in the library and when old ones eventually leave.

API Methods

The MVP surface is deliberately narrow. The endpoints Meta still supports for third-party apps on modern Graph API, plus the token-management primitives.

getMe(array $fields = []): User

GET /me. Empty $fields defers to Meta's default projection. Include fields you want back. email requires the email scope. Name breakdown requires public_profile. And so on. Meta silently omits fields the token cannot see rather than raising an error, so a stripped-down response usually means a stripped-down scope grant.

listMyUpcomingEvents(?Cursor $cursor = null, array $fields = []): PagedIterator

GET /me/events. Requires the user_events permission on the access token (App Review gated by Meta post-2018). Returns a lazy iterator over Event value objects. Paging is handled transparently. The iterator walks Meta's paging.next URLs so callers get every page or break out early to bound cost.

listMyPermissions(): list<Permission>

GET /me/permissions. Meta returns a small, unpaginated list. This method materialises the full array of Permission value objects. Each has name(), status(), and an isGranted() convenience.

revokePermission(string $permission): void

DELETE /me/permissions/{permission}. Revokes a previously-granted scope from the current token. The token itself remains valid but loses access to the revoked scope. Meta returns {"success":true} on success. Anything else raises GraphErrorException.

debugToken(string $inputToken, string $appAccessToken): DebugTokenInfo

GET /debug_token. Introspects a token. The one being examined ($inputToken) is usually a user or client token whose fitness you want to verify. The second token ($appAccessToken) is your app-level token authorising the introspection call (typically "{$appId}|{$appSecret}").

OAuth2 and OIDC

The Facebook package does not re-implement OAuth2. It provides a FacebookProviderConfig factory that returns a Horde\OAuth\Client\ProviderConfig pre-populated with Meta's versioned endpoint URLs. Callers wire the actual authorization flow with Horde\OAuth\Client\OAuth2Client.

Authorization flow

id_token verification (Facebook Login with openid scope)

When you request the openid scope, Meta returns an id_token alongside the access token. The id_token is a signed JWT carrying user identity claims (sub, aud, iss, exp, iat, plus any nonce you passed).

Verification via FacebookOidcSupport:

The helper fetches Meta's JWKS document, selects the key matching the token's kid header, and delegates to Horde\Jwt\TokenDecoder for signature and claims verification. Nonce verification is left to the caller because it involves state you stored between the authorize redirect and the callback.

Error Handling

Every wire error carrying a Meta error envelope becomes a GraphErrorException:

Predicates on GraphError:

Do not string-match $e->getMessage(). Meta rewords error messages without notice. Use the predicates.

Malformed error responses (HTTP 4xx/5xx with no parseable Meta envelope) throw the plain FacebookApiException base class instead. Catch that if you want to handle every failure mode uniformly.

Value Objects

Return types are per-version concrete classes under Horde\Service\Facebook\Graph\Endpoint\V{N}\Value\. For the current default that means V25\Value\User, V25\Value\Event, V25\Value\Permission, and V25\Value\DebugTokenInfo. Each carries version-specific fields as public readonly properties.

For version-portable signatures, type-hint the shared interfaces in Horde\Service\Facebook\Graph\Value\. User, Event, Permission, DebugTokenInfo. These expose only fields present on every supported version's response, via method accessors:

When you need v25-specific fields (rsvpStatus, placeName, coverPhotoUrl), type-hint the concrete class directly and read the public properties OR reflect on capability interfaces

Value objects are pure data holders. They construct from decoded JSON via ::fromApiResponse(object $data): self and have no dependency on the HTTP client, config, or version enum. That makes them independently useful for hydrating stored payloads (database rows, cache entries, replay fixtures), not only live API responses.

Profile URL Helpers

Two pure URL builders. No API call, no token required. For rendering Facebook profile links and profile picture URLs. Corresponds to the legacy client's getProfileLink() and getThumbnail() methods, the only members of the legacy Users module that ported cleanly.

What This Library Does Not Do

Explicitly out of scope for the MVP:

The legacy lib/Horde/Service/Facebook/ tree that targets these features is retained for one release cycle for backward autoload compatibility. Do not use it in new code. It calls endpoints Facebook no longer serves.

For the full catalog of features the library does not currently ship, including known deferrals (long-lived token exchange, batch requests) and larger capability areas (Login-with-Facebook identity mapping, Pages, Meta Business Manager), see doc/MISSING_FEATURES.md.

Legacy Coexistence

The lib/ PSR-0 tree stays in place though largely defunct. The src/ PSR-4 tree is the supported surface. There is no forwarding between them. New callers use the PSR-4 namespace. Old callers keep syntactically correct (against dead endpoints) so no code breaks by merely depending on the classes. Still migration is due.

Migrating existing callers off lib/? Start with doc/UPGRADING.md for the class-to-class map and concrete migration examples.

Testing

Uses PHPUnit 11+. Tests run against test/unit. Integration tests under test/integration require live Facebook credentials via environment variables and are excluded from the default suite.

License

BSD-2-Clause. See LICENSE.


All versions of service_facebook with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
horde/oauth Version ^4 || dev-FRAMEWORK_6_0
horde/jwt Version ^1 || dev-FRAMEWORK_6_0
horde/exception Version ^3 || dev-FRAMEWORK_6_0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package horde/service_facebook contains the following files

Loading the files please wait ...