Since I couldn’t find any documentation on how to integrate Gogobot in PHP I decided to make a blog post about it.
1. Get Client id and Client Secret from Gogobot.
2. Replace $clientId and $clientSecret below with your credentials.
[code lang=”php”]
$clientId = ‘MY ID’;
$clientSecret = ‘MY SECRET’;
$queryParameters = array();
$queryParameters[‘query’] = $query;
$queryParameters[‘lat’] = $lat;
$queryParameters[‘lng’] = $lng;
$queryParameters[‘https’] = (!empty($https) ? 1 : 0);
$queryParameters[‘client_id’] = $clientId;
ksort($queryParameters);
// Calculate payload
$payload = ”;
foreach ($queryParameters as $key => $value)
{
$payload .= $key;
$payload .= $value;
}
$payload .= $clientSecret;
// Generate signature
$signature = hash_hmac(‘sha256’, $payload, $clientSecret, true);
$signature = base64_encode($signature);
$queryParameters[‘signature’] = $signature;
// Generate HTTP
$http = ‘http://api.gogobot.com/api/v3/search/nearby_search/?’;
$queryParameterIndex = 0;
foreach ($queryParameters as $key => $value)
{
if ($queryParameterIndex > 0) {
$http .= ‘&’;
}
$http .= $key . ‘=’ . rawurlencode($value);
$queryParameterIndex++;
}
[/code]
3. After this just make a cURL request and the integration is ready.