Skip to content

Commit

Permalink
Fix to LinkedIn API v2
Browse files Browse the repository at this point in the history
  • Loading branch information
sireko committed Aug 30, 2019
1 parent 58bb3bc commit c98f6c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
/build/
composer.lock
index.php
Expand Down
9 changes: 8 additions & 1 deletion src/LinkedIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function api($method, $resource, array $options = [])
isset($options['query']) ? $options['query'] : []
);

$body = isset($options['body']) ? $options['body'] : null;
$body = isset($options['json']) ? json_encode($options['json']) : null;
$this->lastResponse = $this->getRequestManager()->sendRequest($method, $url, $options['headers'], $body);

//Get the response data format
Expand All @@ -142,6 +142,9 @@ public function api($method, $resource, array $options = [])
*/
protected function filterRequestOption(array &$options)
{
// Updated by sireko for good working in v2 API

/*
if (isset($options['json'])) {
$options['format'] = 'json';
$options['body'] = json_encode($options['json']);
Expand All @@ -163,6 +166,10 @@ protected function filterRequestOption(array &$options)
default:
// Do nothing
}
*/

$options['headers']['Content-Type'] = 'application/json';
$options['headers']['x-li-format'] = 'json';

return $options['format'];
}
Expand Down

0 comments on commit c98f6c2

Please sign in to comment.