/**
  * Makes a batched request to Graph and returns the result.
  *
  * @param FacebookBatchRequest $request
  *
  * @return FacebookBatchResponse
  *
  * @throws FacebookSDKException
  */
 public function sendBatchRequest(FacebookBatchRequest $request)
 {
     $request->prepareRequestsForBatch();
     $facebookResponse = $this->sendRequest($request);
     return new FacebookBatchResponse($facebookResponse);
 }
 private function createAndAppendRequestsTo(FacebookBatchRequest $batchRequest, $number)
 {
     for ($i = 0; $i < $number; $i++) {
         $batchRequest->add(new FacebookRequest());
     }
 }
 public function testPreppingABatchRequestProperlySetsThePostParams()
 {
     $app = new FacebookApp('123', 'foo_secret');
     $batchRequest = new FacebookBatchRequest($app, 'foo_token');
     $batchRequest->add(new FacebookRequest(null, 'bar_token', 'GET', '/foo'), 'foo_name');
     $batchRequest->add(new FacebookRequest(null, null, 'POST', '/bar', ['foo' => 'bar']));
     $batchRequest->prepareRequestsForBatch();
     $params = $batchRequest->getParams();
     $expectedHeaders = json_encode($this->requestHeaders);
     $version = FacebookRequest::getDefaultGraphApiVersion();
     $expectedBatchParams = ['batch' => '[{"headers":' . $expectedHeaders . ',"method":"GET","relative_url":"\\/' . $version . '\\/foo?access_token=bar_token&appsecret_proof=2ceec40b7b9fd7d38fff1767b766bcc6b1f9feb378febac4612c156e6a8354bd","name":"foo_name"},' . '{"headers":' . $expectedHeaders . ',"method":"POST","relative_url":"\\/' . $version . '\\/bar","body":"foo=bar&access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9"}]', 'include_headers' => true, 'access_token' => 'foo_token', 'appsecret_proof' => 'df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9'];
     $this->assertEquals($expectedBatchParams, $params);
 }