Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/Splash/LinkedIn/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public function __construct($api_key, $api_secret, $curl = null) {
* @param string $method
* @return array
*/
public function fetch($resource, array $payload = array(), $method = 'GET') {
public function fetch($resource, array $payload = array(), $method = 'GET', $postData = null) {
$url = $this->domain . $resource;

$payload = array('oauth2_access_token' => $this->getAccessToken(), 'format' => 'json')
+ $payload;

return $this->_request($url, $payload, $method);
return $this->_request($url, $payload, $method, $postData);
}

/**
Expand Down Expand Up @@ -117,10 +117,10 @@ public function fetchAccessToken($verification_code, $redirect_uri) {
* @return array JSON-decoded response
* @throws Exception
*/
protected function _request($url, array $payload = array(), $method = 'GET') {
protected function _request($url, array $payload = array(), $method = 'GET', $postData = null) {
$ch = $this->getCurl();

if (!empty($payload) && $method == 'GET') {
if (!empty($payload) && $method == 'GET' || (!empty($postData) && $method == 'POST')) {
$url .= "?" . http_build_query($payload);
}

Expand All @@ -132,7 +132,9 @@ protected function _request($url, array $payload = array(), $method = 'GET') {
case 'POST':
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: multipart/form-data'));
if (!empty($payload))
if(!empty($postData))
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
elseif (!empty($payload))
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));
break;
case 'PUT':
Expand Down Expand Up @@ -241,4 +243,4 @@ public function getCurl() {

return $this->curl;
}
}
}