Google API - Need help with cURL and Post Requests


I’m trying to create a simple sub-account using Google’s API. Here is the example they provided: . Basically, I need help trying to convert Google’s example into cURL so I can run these requests more easily.

This is what I came up with so far and it’s not working:

$headers = array(
'POST  /content/v1/MULTI_CLIENT_ACCOUNT_ID/managedaccounts HTTP/1.1',
'Content-Type: application/atom+xml',
'Authorization: GoogleLogin auth=AUTHORIZATION_TOKEN'

$requestXmlBody ="
<?xml version='1.0'?>
<entry xmlns=''
  <title type='text'>John</title>
  <content type='text'>John's Store</content>
  <link rel='alternate' type='text/html' href=''/>

$connection = curl_init();
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
curl_setopt($connection, CURLOPT_POST, 1);
curl_setopt($connection, CURLOPT_POSTFIELDS, $requestXmlBody);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($connection); print_r($response);
if(stristr($response, 'HTTP 404') || $response == "") {
    die('<P>Error sending request');

One line of the header has this: Authorization: GoogleLogin auth=AUTHORIZATION_TOKEN

I have no idea how to get the Authorization_Token. I’m new the whole Google API thing with requests and tokens. I’m hoping someone here knows the simplest, clean way of obtaining the token?

Kind regards

Any help?!topic/android-developers/c27iKS4s-E0