Skip to content

Commit

Permalink
Updated SDK to 5.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Filippo Rossi committed Apr 28, 2017
1 parent dccbe17 commit 24e48f4
Show file tree
Hide file tree
Showing 77 changed files with 227 additions and 103 deletions.
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/Authentication/AccessToken.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/Authentication/AccessTokenMetadata.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/Authentication/OAuth2Client.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/Exceptions/FacebookAuthenticationException.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/Exceptions/FacebookAuthorizationException.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/Exceptions/FacebookClientException.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/Exceptions/FacebookOtherException.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/Exceptions/FacebookResponseException.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/Exceptions/FacebookResumableUploadException.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/Exceptions/FacebookSDKException.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/Exceptions/FacebookServerException.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/Exceptions/FacebookThrottleException.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
27 changes: 24 additions & 3 deletions myfbconnect/src/Facebook/Facebook.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down Expand Up @@ -53,12 +53,12 @@ class Facebook
/**
* @const string Version number of the Facebook PHP SDK.
*/
const VERSION = '5.4.0';
const VERSION = '5.5.0';

/**
* @const string Default Graph API version for requests.
*/
const DEFAULT_GRAPH_VERSION = 'v2.8';
const DEFAULT_GRAPH_VERSION = 'v2.9';

/**
* @const string The name of the environment variable that contains the app ID.
Expand Down Expand Up @@ -494,6 +494,27 @@ public function sendBatchRequest(array $requests, $accessToken = null, $graphVer
return $this->lastResponse = $this->client->sendBatchRequest($batchRequest);
}

/**
* Instantiates an empty FacebookBatchRequest entity.
*
* @param AccessToken|string|null $accessToken The top-level access token. Requests with no access token
* will fallback to this.
* @param string|null $graphVersion The Graph API version to use.
* @return FacebookBatchRequest
*/
public function newBatchRequest($accessToken = null, $graphVersion = null)
{
$accessToken = $accessToken ?: $this->defaultAccessToken;
$graphVersion = $graphVersion ?: $this->defaultGraphVersion;

return new FacebookBatchRequest(
$this->app,
[],
$accessToken,
$graphVersion
);
}

/**
* Instantiates a new FacebookRequest entity.
*
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/FacebookApp.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
67 changes: 44 additions & 23 deletions myfbconnect/src/Facebook/FacebookBatchRequest.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down Expand Up @@ -62,16 +62,17 @@ public function __construct(FacebookApp $app = null, array $requests = [], $acce
}

/**
* A a new request to the array.
* Adds a new request to the array.
*
* @param FacebookRequest|array $request
* @param string|null $name
* @param string|null|array $options Array of batch request options e.g. 'name', 'omit_response_on_success'.
* If a string is given, it is the value of the 'name' option.
*
* @return FacebookBatchRequest
*
* @throws \InvalidArgumentException
*/
public function add($request, $name = null)
public function add($request, $options = null)
{
if (is_array($request)) {
foreach ($request as $key => $req) {
Expand All @@ -85,17 +86,28 @@ public function add($request, $name = null)
throw new \InvalidArgumentException('Argument for add() must be of type array or FacebookRequest.');
}

if (null === $options) {
$options = [];
} elseif (!is_array($options)) {
$options = ['name' => $options];
}

$this->addFallbackDefaults($request);

// File uploads
$attachedFiles = $this->extractFileAttachments($request);

$name = isset($options['name']) ? $options['name'] : null;

unset($options['name']);

$requestToAdd = [
'name' => $name,
'request' => $request,
'options' => $options,
'attached_files' => $attachedFiles,
];

// File uploads
$attachedFiles = $this->extractFileAttachments($request);
if ($attachedFiles) {
$requestToAdd['attached_files'] = $attachedFiles;
}
$this->requests[] = $requestToAdd;

return $this;
Expand Down Expand Up @@ -189,8 +201,15 @@ public function convertRequestsToJson()
{
$requests = [];
foreach ($this->requests as $request) {
$attachedFiles = isset($request['attached_files']) ? $request['attached_files'] : null;
$requests[] = $this->requestEntityToBatchArray($request['request'], $request['name'], $attachedFiles);
$options = [];

if (null !== $request['name']) {
$options['name'] = $request['name'];
}

$options += $request['options'];

$requests[] = $this->requestEntityToBatchArray($request['request'], $options, $request['attached_files']);
}

return json_encode($requests);
Expand All @@ -215,14 +234,22 @@ public function validateBatchRequestCount()
/**
* Converts a Request entity into an array that is batch-friendly.
*
* @param FacebookRequest $request The request entity to convert.
* @param string|null $requestName The name of the request.
* @param string|null $attachedFiles Names of files associated with the request.
* @param FacebookRequest $request The request entity to convert.
* @param string|null|array $options Array of batch request options e.g. 'name', 'omit_response_on_success'.
* If a string is given, it is the value of the 'name' option.
* @param string|null $attachedFiles Names of files associated with the request.
*
* @return array
*/
public function requestEntityToBatchArray(FacebookRequest $request, $requestName = null, $attachedFiles = null)
public function requestEntityToBatchArray(FacebookRequest $request, $options = null, $attachedFiles = null)
{

if (null === $options) {
$options = [];
} elseif (!is_array($options)) {
$options = ['name' => $options];
}

$compiledHeaders = [];
$headers = $request->getHeaders();
foreach ($headers as $name => $value) {
Expand All @@ -242,18 +269,12 @@ public function requestEntityToBatchArray(FacebookRequest $request, $requestName
$batch['body'] = $body;
}

if (isset($requestName)) {
$batch['name'] = $requestName;
}
$batch += $options;

if (isset($attachedFiles)) {
if (null !== $attachedFiles) {
$batch['attached_files'] = $attachedFiles;
}

// @TODO Add support for "omit_response_on_success"
// @TODO Add support for "depends_on"
// @TODO Add support for JSONP with "callback"

return $batch;
}

Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/FacebookBatchResponse.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/FacebookClient.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
4 changes: 2 additions & 2 deletions myfbconnect/src/Facebook/FacebookRequest.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down Expand Up @@ -108,7 +108,7 @@ public function __construct(FacebookApp $app = null, $accessToken = null, $metho
/**
* Set the access token for this request.
*
* @param AccessToken|string
* @param AccessToken|string|null
*
* @return FacebookRequest
*/
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/FacebookResponse.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/FileUpload/FacebookFile.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/FileUpload/FacebookResumableUploader.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/FileUpload/FacebookTransferChunk.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/FileUpload/FacebookVideo.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
3 changes: 2 additions & 1 deletion myfbconnect/src/Facebook/FileUpload/Mimetypes.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down Expand Up @@ -724,6 +724,7 @@ class Mimetypes
'spq' => 'application/scvp-vp-request',
'spx' => 'audio/ogg',
'src' => 'application/x-wais-source',
'srt' => 'application/octet-stream',
'sru' => 'application/sru+xml',
'srx' => 'application/sparql-results+xml',
'sse' => 'application/vnd.kodak-descriptor',
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/GraphNodes/Birthday.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/GraphNodes/Collection.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
2 changes: 1 addition & 1 deletion myfbconnect/src/Facebook/GraphNodes/GraphAchievement.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright 2016 Facebook, Inc.
* Copyright 2017 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
Expand Down
Loading

0 comments on commit 24e48f4

Please sign in to comment.