Google API - Need help with cURL and Post Requests

Greetings,

I’m trying to create a simple sub-account using Google’s API. Here is the example they provided: https://developers.google.com/shopping-content/multiclientaccounts/mcaccounts#create-client-account . 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',
'Host: content.googleapis.com',
'Content-Type: application/atom+xml',
'Authorization: GoogleLogin auth=AUTHORIZATION_TOKEN'
);

$requestXmlBody ="
<?xml version='1.0'?>
<entry xmlns='http://www.w3.org/2005/Atom'
    xmlns:sc='http://schemas.google.com/structuredcontent/2009'>
  <title type='text'>John</title>
  <content type='text'>John's Store</content>
  <link rel='alternate' type='text/html' href='http://www.mysite.com/members/john/'/>
  <sc:adult_content>no</sc:adult_content>
  <sc:internal_id>john</sc:internal_id>
  <sc:reviews_url>http://www.mysite.com/reviews/john/</sc:reviews_url>
</entry>";

$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);
curl_close($connection); 
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?

Thanks
Kind regards

Any help? https://groups.google.com/forum/#!topic/android-developers/c27iKS4s-E0