Skip to content

Instantly share code, notes, and snippets.

@thilinag

thilinag/surge.php

Created May 12, 2017
Embed
What would you like to do?
Check surge multiplier
<?php
$ch = curl_init();
$headers[] = "Authorization: Token YOUR_TOKEN";
$headers[] = "Accept-Language: en_US";
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//get surge from old api. v1.2 surge multiplier is not available because we have upfront pricing now.
curl_setopt($ch, CURLOPT_URL, 'https://api.uber.com/v1/estimates/price?start_latitude='.$argv[1].'&start_longitude='.$argv[2].'&end_latitude='.$argv[1].'&end_longitude='.$argv[2]);
$content = curl_exec($ch);
$surge = json_decode($content)->prices[0]->surge_multiplier;
echo ($surge==1?'No surge':$surge.'x surge') . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.