paresh_thummar 0 Newbie Poster

Hello friends,
I am learning google API I want to retrieve google contacts using Authsub. And second thing is that i want to use secure token. I have X.509 certificate with private key.
In first step I got token but in second step (To get AuthSubSessionToken) I got error : Invalid AuthSub token. Here my code. please, anybody have idea ?
Help me....

$url = "https://www.google.com/accounts/AuthSubSessionToken";
$token = $token;
$param['sigalg'] = "rsa-sha1";
$nonce = "15948".time()."49418";  // any random no(20 digit)
$param['data'] = "GET https://www.google.com/accounts/AuthSubSessionToken ".time()." ".$nonce;		
$private_key = "MY_PRIVATE_KEY";
		
$kvpairs = array();
foreach ($param as $k => $v) {
array_push($kvpairs, ($k . '=' . $v));
}		
	$query_string = '';
	$query_string = implode('&', $kvpairs);
	$base_string = 'GET'.'&'.$url .'&'.$query_string;
	$param['sig'] =  base64_encode(hash_hmac('sha1', $base_string, $private_key, true));
	uksort($param, 'strcmp');
	$header = 'Authorization: AuthSub token="'.$token.'" ';
        foreach ($param as $k => $v) 
        {
        	$header .= $k . '="' .$v. '" ';
        }
        
        $header = trim($header," ");
	$headers[]= $header;
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL,$url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	$responce = curl_exec($ch);
	curl_close($ch);