Skip to content

Commit

Permalink
Update #6 - Post method return data
Browse files Browse the repository at this point in the history
Added:
- Return data for getAccountInfo() in Client class
- Return data for getUserDetails in Client class
- Curl now return data for POST requests
  • Loading branch information
Necko1996 committed Feb 11, 2019
1 parent 8300ecc commit efd2060
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function removeWebhook()

public function getAccountInfo()
{
Http::call('POST', 'get_account_info');
return Http::call('POST', 'get_account_info');
}

/**
Expand All @@ -33,7 +33,7 @@ public function getOnlineStatus(array $userIds)

public function getUserDetails($user_id)
{
Http::call('POST', 'get_user_details', ['id' => $user_id]);
return Http::call('POST', 'get_user_details', ['id' => $user_id]);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/Http/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public static function call(string $method, string $url, array $body = [], bool

if ($method === 'POST') {
$curl->post(($baseUrlActive ? static::$BASE_URL : '').$url, json_encode($body));

if ($curl->error) {
return json_encode('Error: '.$curl->errorCode.': '.$curl->errorMessage."\n");
}

return $curl->response;
}

if ($method === 'GET') {
Expand Down

0 comments on commit efd2060

Please sign in to comment.