Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All version API exsept v4 will send API-KEY as header entry. #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "route4me/route4me-php",
"description": "Access Route4Me's logistics-as-a-service API using our PHP SDK",
"minimum-stability": "stable",
"version": "1.3.1",
"version": "1.3.2",
"authors": [
{
"name": "Igor Route4Me",
Expand Down
18 changes: 12 additions & 6 deletions src/Route4Me/Route4Me.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,19 @@ public static function makeRequst($options)

$ch = curl_init();

$url = isset($options['url'])
? $options['url'] . '?' . http_build_query(array_merge(
$query,
['api_key' => self::getApiKey()]
)) : '';

$baseUrl = self::getBaseUrl();
$host = parse_url($baseUrl . (isset($options['url']) ? $options['url'] : ''), PHP_URL_HOST);
$url = null;
if (isset($host) && strtolower(substr($host, 0, 2)) == "wh") {
$url = (isset($options['url']) ? $options['url'] . '?' . http_build_query($query) : '');
$headers[] = 'Authorization: Bearer ' . self::getApiKey();
} else {
$url = (isset($options['url'])
? $options['url'] . '?' . http_build_query(array_merge(
$query,
['api_key' => self::getApiKey()]
)) : '');
}

$curlOpts = [
CURLOPT_URL => $baseUrl.$url,
Expand Down