I'm trying to post photo.pose.level on existing photo using Street View Publish API.
When i post GPS, HEADING and LEVEL data, first two (GPS+HEADING) are stored on street view photo, but LEVEL data is lost and won't save (server response is OK).
Here is my POST code that works for HEADING and GPS, i can't figure out where i'm wrong or if i'm missing something.. i think i've done all as described in documentation
$data['pose']['latLngPair']['latitude']=$lat+0;
$data['pose']['latLngPair']['longitude']=$lon+0;
$data['pose']['heading']=$heading+0;
$data['pose']['level']['number']=$level+0;
$data['pose']['level']['name']='L'.($level+0).'';
$data_string = json_encode($data);
$ch = curl_init('https://streetviewpublish.googleapis.com/v1/photo/'.$photo_id.'?key='.$_GOOGLE_API['api_key'].'&updateMask=pose.latLngPair,pose.heading,pose.level');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'authorization: Bearer '.$_GOOGLE_API['access_token'],
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$json_response=curl_exec($ch);
curl_close ($ch);
Looks good. How long did you wait? Sometimes it takes up to 24hrs before the data shows up in the getPhoto requests.
Related
While I am able to receive the initial Strava oAuth Code through the authorize? process on the Strava page, I am struggling with the token exchange process described here: https://developers.strava.com/docs/authentication/
Code below does only result in
Sorry, this one stays red.
The page you’re looking for doesn’t exist, but you’re not at a dead end.
Here are a few options:
Be sure you have the right url and try again
Sign up or log in at strava.com
See what the community’s been up to at Strava Stories
Search for a particular activity or club
Get a little help from Strava Support
I am quite new to the Strava API, but also directly pasting the resulting URL in the browser does result in the same page response.
$url = "https://www.strava.com/oauth/token?client_id=XXXXX&client_secret=XXXXXXXXXXXXXXXXXXXXXXXX&code=".$code."&grant_type=authorization_code";
echo "<br />".$url;
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_HTTPGET, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json'
));
$result = curl_exec($cURL);
curl_close($cURL);
print_r($result);
?>
Thanks in Advance for your support on this matter !
#Chris White solved it, was using POST instead of GET. Thanks for the help
echo "<br />".$url;
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_POST, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json'
));
$result = curl_exec($cURL);
curl_close($cURL);
print_r($result);
?>
I have a PHP-7 application which needs to access the Google Shopping API (OAuth2.0 ...) from the back-end servers. In other words, it must use CURL. I am looking for as complete an example as possible – from any source.
I do not want to use Google's code which first of all doesn't seem to use CURL and second of all seems to involve over 7,000 new PHP source-files.
Many APIs seem to reference $_GET[] as though the requesting agent was itself "a web page." In this case, it is not: the requests are being made using CURL, and must be so.
This should work
$data = array("post" => $vars, "post2" => $vars2);
$data_string = json_encode($data);
$ch = curl_init('https://endpoint.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' . $oauth_key,
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$output = curl_exec($ch);
I'm trying to upload spherical images on street view using Publish Api.
Upload of image data and place association works well, but whenever i try to upload heading and gps position data to the image server responds "OK" but then no heading nor position were associated to the image.
Here is the php code i use for the last step of info upload, i really don't know where i am wrong.
$data['uploadReference']['uploadUrl']=$upload_url;
$data['pose']['heading']=$heading_north;
$data['pose']['latLngPair']=$latLngPair;
$data['captureTime']['seconds']=time();
$data['places']['placeId']=$placeid;
$data_string = json_encode($data);
$ch = curl_init('https://streetviewpublish.googleapis.com/v1/photo?key='.$_GOOGLE_API['api_key']);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'authorization: Bearer '.$_GOOGLE_API['access_token'],
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
curl_close ($ch);
EDIT:
I've implemented the second step as suggested but nothing changes..
Curl response still doesn't contains any error..
$ch = curl_init('https://streetviewpublish.googleapis.com/v1/photo/'.$photo_id.'?key='.$_GOOGLE_API['api_key'].'&updateMask=pose.heading');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'authorization: Bearer '.$_GOOGLE_API['access_token'],
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$json_response=curl_exec($ch);
curl_close ($ch);
echo $json_response;
EDIT2: this procedure works but google apis are slow and edited data will show up in minutes..
EDIT3 (SOLVED): GET photos (list) has some chache issue. to get the correct value just updated you need to request GET photo (single) to force an effective cache update.
Try to set the values in a second step with photo.update. Don't forget to set the updateMask for the values.
I am trying to follow instructions from an RFC spec to retrieve data from "certificate transparency log" known logs here
Instructions say to make a JSON call but i don't seem to be having any success.. i actually don't get any data response at all.
Here is the guide I am trying to follow:
https://www.rfc-editor.org/rfc/rfc6962#section-4.6
Here is the php code I am using
<?php
$data = array("start" => "1", "end" => "10");
$data_string = json_encode($data);
$ch = curl_init('https://ct.googleapis.com/pilot/ct/v1/get-entries');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
var_dump(json_decode($result, true));
?>
The service I was connecting to has an SSL certificate installed and was not responding to my requests. Disabling the trust verification was the solution. I added this to the CURL options CURLOPT_SSL_VERIFYPEER => false
llo,
I'm trying to integrate my webapp with RESTful api in php. This requires me to POST data to https://api.api.ai/v1/query and also have 2 custom headers.
my current code is
$data = array("v" => "20150821", "query" => "whats the time", "lang" => "EN", "sessionId" => "1234567890");
$data_string = json_encode($data);
$ch = curl_init('https://api.api.ai/v1/query');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
// 'Content-Length: ' . strlen($data_string),
'Content-type: application/json',
'Authorization: Bearer XxxX-xxx',
'ocp-apim-subscription-key: XxxX-xxx')
);
$result = curl_exec($ch);
If i run this, (with my real auth and key obv) i get nothing. Like Blank. Any ideas?
I AM SO SORRY.
I havent been sleeping well and did a rather idiotic mistake
i forgot to echo $result
i know, i know. I'll have to be a bit more careful
Thanks anyway :P