diff options
author | emkael <emkael@tlen.pl> | 2019-01-01 17:11:00 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-01-01 17:11:00 +0100 |
commit | 36f25b4e845b9a53dd6f11402de5bfa61078fdf9 (patch) | |
tree | 9cf8ee811f2e6c6fb5f90e6001d45d347f969b01 /lib/facebook-graph-sdk/src | |
parent | eab8a101e7a3fcbb41e01a574985e06c5a3775de (diff) |
Facebook API updated
Diffstat (limited to 'lib/facebook-graph-sdk/src')
11 files changed, 85 insertions, 9 deletions
diff --git a/lib/facebook-graph-sdk/src/Facebook/Exceptions/FacebookResponseException.php b/lib/facebook-graph-sdk/src/Facebook/Exceptions/FacebookResponseException.php index 4a135db..e51f1c8 100644 --- a/lib/facebook-graph-sdk/src/Facebook/Exceptions/FacebookResponseException.php +++ b/lib/facebook-graph-sdk/src/Facebook/Exceptions/FacebookResponseException.php @@ -90,11 +90,20 @@ class FacebookResponseException extends FacebookSDKException // Video upload resumable error case 1363030: case 1363019: - case 1363037: case 1363033: case 1363021: case 1363041: return new static($response, new FacebookResumableUploadException($message, $code)); + case 1363037: + $previousException = new FacebookResumableUploadException($message, $code); + + $startOffset = isset($data['error']['error_data']['start_offset']) ? (int) $data['error']['error_data']['start_offset'] : null; + $previousException->setStartOffset($startOffset); + + $endOffset = isset($data['error']['error_data']['end_offset']) ? (int) $data['error']['error_data']['end_offset'] : null; + $previousException->setEndOffset($endOffset); + + return new static($response, $previousException); } } diff --git a/lib/facebook-graph-sdk/src/Facebook/Exceptions/FacebookResumableUploadException.php b/lib/facebook-graph-sdk/src/Facebook/Exceptions/FacebookResumableUploadException.php index 6f47066..6d41c63 100644 --- a/lib/facebook-graph-sdk/src/Facebook/Exceptions/FacebookResumableUploadException.php +++ b/lib/facebook-graph-sdk/src/Facebook/Exceptions/FacebookResumableUploadException.php @@ -30,4 +30,39 @@ namespace Facebook\Exceptions; */ class FacebookResumableUploadException extends FacebookSDKException { + protected $startOffset; + + protected $endOffset; + + /** + * @return int|null + */ + public function getStartOffset() + { + return $this->startOffset; + } + + /** + * @param int|null $startOffset + */ + public function setStartOffset($startOffset) + { + $this->startOffset = $startOffset; + } + + /** + * @return int|null + */ + public function getEndOffset() + { + return $this->endOffset; + } + + /** + * @param int|null $endOffset + */ + public function setEndOffset($endOffset) + { + $this->endOffset = $endOffset; + } } diff --git a/lib/facebook-graph-sdk/src/Facebook/Facebook.php b/lib/facebook-graph-sdk/src/Facebook/Facebook.php index bf93119..03a5234 100644 --- a/lib/facebook-graph-sdk/src/Facebook/Facebook.php +++ b/lib/facebook-graph-sdk/src/Facebook/Facebook.php @@ -53,7 +53,7 @@ class Facebook /** * @const string Version number of the Facebook PHP SDK. */ - const VERSION = '5.6.2'; + const VERSION = '5.7.0'; /** * @const string Default Graph API version for requests. diff --git a/lib/facebook-graph-sdk/src/Facebook/FacebookBatchRequest.php b/lib/facebook-graph-sdk/src/Facebook/FacebookBatchRequest.php index 3d5d5d5..9297e77 100644 --- a/lib/facebook-graph-sdk/src/Facebook/FacebookBatchRequest.php +++ b/lib/facebook-graph-sdk/src/Facebook/FacebookBatchRequest.php @@ -39,7 +39,7 @@ class FacebookBatchRequest extends FacebookRequest implements IteratorAggregate, /** * @var array An array of FacebookRequest entities to send. */ - protected $requests; + protected $requests = []; /** * @var array An array of files to upload. diff --git a/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookResumableUploader.php b/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookResumableUploader.php index 92a22f1..46a2727 100644 --- a/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookResumableUploader.php +++ b/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookResumableUploader.php @@ -121,6 +121,16 @@ class FacebookResumableUploader throw $e; } + if (null !== $preException->getStartOffset() && null !== $preException->getEndOffset()) { + return new FacebookTransferChunk( + $chunk->getFile(), + $chunk->getUploadSessionId(), + $chunk->getVideoId(), + $preException->getStartOffset(), + $preException->getEndOffset() + ); + } + // Return the same chunk entity so it can be retried. return $chunk; } diff --git a/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookTransferChunk.php b/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookTransferChunk.php index a909e87..99ea775 100644 --- a/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookTransferChunk.php +++ b/lib/facebook-graph-sdk/src/Facebook/FileUpload/FacebookTransferChunk.php @@ -122,6 +122,14 @@ class FacebookTransferChunk } /** + * @return int + */ + public function getEndOffset() + { + return $this->endOffset; + } + + /** * Get uploaded video Id * * @return int diff --git a/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphNode.php b/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphNode.php index 061e744..a81c47b 100644 --- a/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphNode.php +++ b/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphNode.php @@ -150,7 +150,8 @@ class GraphNode extends Collection 'backdated_time', 'issued_at', 'expires_at', - 'publish_time' + 'publish_time', + 'joined' ], true); } diff --git a/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphNodeFactory.php b/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphNodeFactory.php index 6a37091..937128b 100644 --- a/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphNodeFactory.php +++ b/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphNodeFactory.php @@ -304,7 +304,9 @@ class GraphNodeFactory return $this->safelyMakeGraphEdge($data, $subclassName, $parentKey, $parentNodeId); } // Sometimes Graph is a weirdo and returns a GraphNode under the "data" key - $data = $data['data']; + $outerData = $data; + unset($outerData['data']); + $data = $data['data'] + $outerData; } // Create GraphNode diff --git a/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphPage.php b/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphPage.php index 3dfb0e0..503b96b 100644 --- a/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphPage.php +++ b/lib/facebook-graph-sdk/src/Facebook/GraphNodes/GraphPage.php @@ -144,4 +144,14 @@ class GraphPage extends GraphNode { return $this->getField('perms'); } + + /** + * Returns the `fan_count` (Number of people who likes to page) as int if present. + * + * @return int|null + */ + public function getFanCount() + { + return $this->getField('fan_count'); + } } diff --git a/lib/facebook-graph-sdk/src/Facebook/Helpers/FacebookRedirectLoginHelper.php b/lib/facebook-graph-sdk/src/Facebook/Helpers/FacebookRedirectLoginHelper.php index 3240ba8..6003a20 100644 --- a/lib/facebook-graph-sdk/src/Facebook/Helpers/FacebookRedirectLoginHelper.php +++ b/lib/facebook-graph-sdk/src/Facebook/Helpers/FacebookRedirectLoginHelper.php @@ -222,8 +222,8 @@ class FacebookRedirectLoginHelper $this->resetCsrf(); $redirectUrl = $redirectUrl ?: $this->urlDetectionHandler->getCurrentUrl(); - // At minimum we need to remove the 'state' and 'code' params - $redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl, ['code', 'state']); + // At minimum we need to remove the 'code', 'enforce_https' and 'state' params + $redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl, ['code', 'enforce_https', 'state']); return $this->oAuth2Client->getAccessTokenFromCode($code, $redirectUrl); } diff --git a/lib/facebook-graph-sdk/src/Facebook/Http/GraphRawResponse.php b/lib/facebook-graph-sdk/src/Facebook/Http/GraphRawResponse.php index d1a7241..44105c4 100644 --- a/lib/facebook-graph-sdk/src/Facebook/Http/GraphRawResponse.php +++ b/lib/facebook-graph-sdk/src/Facebook/Http/GraphRawResponse.php @@ -104,8 +104,9 @@ class GraphRawResponse */ public function setHttpResponseCodeFromHeader($rawResponseHeader) { - preg_match('|HTTP/\d\.\d\s+(\d+)\s+.*|', $rawResponseHeader, $match); - $this->httpResponseCode = (int)$match[1]; + // https://tools.ietf.org/html/rfc7230#section-3.1.2 + list($version, $status, $reason) = array_pad(explode(' ', $rawResponseHeader, 3), 3, null); + $this->httpResponseCode = (int) $status; } /** |