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 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

FacebookBatchResponse for the Facebook SDK for PHP

Represents a batch response returned from the Graph API.

Facebook\BatchResponse

After sending a batch request to the Graph API, the response will be returned in the form of a Facebook\BatchResponse entity.

Usage:

$fb = new Facebook\Facebook(/* . . . */);
$requests = [
  $fb->request('GET', '/me'),
  $fb->request('POST', '/me/feed', [/* */]),
];

// Send the batch request to Graph
try {
  $batchResponse = $fb->sendBatchRequest($requests, '{access-token}');
} catch(Facebook\Exception\ResponseException $e) {
  // When Graph returns an error
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exception\SDKException $e) {
  // When validation fails or other local issues
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}

foreach ($batchResponse as $key => $response) {
  if ($response->isError()) {
    $error = $response->getThrownException();
    echo $key . ' error: ' . $error->getMessage();
  } else {
    // Success
  }
}

var_dump($batchResponse);
// class Facebook\BatchResponse . . .

Instance Methods

Since the Facebook\BatchResponse is extended from the Facebook\Response entity, all the methods are inherited.

getResponses()

public array getResponses()

Returns the array of Facebook\Response entities that were returned from Graph.

Array Access

Since Facebook\BatchResponse implements \IteratorAggregate and \ArrayAccess, the responses can be accessed via array syntax and can also be iterated over.

$requests = [
  'foo' => $fb->request('GET', '/me'),
  'bar' => $fb->request('POST', '/me/feed', [/* */]),
];
$batchResponse = $fb->sendBatchRequest($requests);

foreach ($batchResponse as $key => $response) {
  if ($response->isError()) {
    $error = $response->getThrownException();
    echo $key . ' error: ' . $error->getMessage();
  } else {
    // Success
  }
}

var_dump($batchResponse['foo']);
// class Facebook\Response . . .
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.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony