Hi,
I have been struggling with getting a service account up and running using the google-api-php-client library.
Its failing when I try to modify the data (update or insert).
It works when I run simple queries.
See below code for examples of both queries.
When I try to insert data I get the following error:
I really don't know where I'm going wrong, Im pretty sure everything is setup correctly on the api console, table is public.
Advice greatly appreciated!!!
<--------------------------------------------------------------------------------------------------------------------------->
// Set your client id, service account name, and the path to your private key.
// For more information about obtaining these keys, visit:
// Make sure you keep your key.p12 file in a secure location, and isn't
// readable by others.
const KEY_FILE = 'mykeypath';
$client = new Google_Client();
$client->setApplicationName("my app name");
// Load the key in PKCS 12 format (you need to download this from the
// Google API Console when the service account was created.
$key = file_get_contents(KEY_FILE);
$client->setAssertionCredentials(new Google_AssertionCredentials(
SERVICE_ACCOUNT_NAME,
$key)
);
$client->setClientId(CLIENT_ID);
$service = new Google_FusiontablesService($client);
$insQuery = "INSERT INTO 1P8kJGgBvCYHOHWbPJwf8b8TtykociMAyzWq8Pz4 (stat_id, latitude, longitude, stat_type) VALUES ('2532', 55.664503, 12.59953, 'c')";
// $selQuery = "select * from 1P8kJGgBvCYHOHWbPJwf8b8TtykociMAyzWq8Pz4 where rowid = '1'";
$res = $service->query->sql($insQuery);
<--------------------------------------------------------------------------------------------------------------------------->
I tried also calling:
$client::$auth->refreshTokenWithAssertion();
after
$client->setAssertionCredentials(new Google_AssertionCredentials(...);
No affect ;(
KR,
Bob.