I am using this code to create a google contact with 2 legged authentication
for a marketplace app, but i am getting "Fatal error: Uncaught exception
'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got
401 " ....
please someone help if i m missing something ..already tested with the 3
Legged and ClientLogin authentication, but i want 2 legged authentication
i already gone through all the disscussion on this forum .. but still i am
unable to find the solution...
-> Scopes are correctly written in manifiest file
-> and reading contacts with 2 legged is working but creating, modifying and
deleting contacts is to be done yet
$oauthOptions = array(
'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
'version' => '1.0',
'signatureMethod' => 'HMAC-SHA1',
'consumerKey' => '1024840357488.apps.googleusercontent.com',
'consumerSecret' => 'ly00OQMi_nEqK4tjaeUiF6z1'
);
$consumer = new Zend_Oauth_Consumer($oauthOptions);
$token = new Zend_Oauth_Token_Access();
$httpClient = $token->getHttpClient($oauthOptions);
$gdata = new Zend_Gdata($httpClient);
$gdata->setMajorProtocolVersion(3);
$doc = new DOMDocument();
$doc->formatOutput = true;
$entry = $doc->createElement('atom:entry');
$entry->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:atom',
'http://www.w3.org/2005/Atom');
$entry->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:gd',
'http://schemas.google.com/g/2005');
$doc->appendChild($entry);
$name = $doc->createElement('gd:name');
$entry->appendChild($name);
$fullName = $doc->createElement('gd:fullName', 'Gaurav Tomer');
$name->appendChild($fullName);
$email = $doc->createElement('gd:email');
$email->setAttribute('address','tomer.24aug07%40dancexd.com');
$email->setAttribute('rel' ,'http://schemas.google.com/g/2005#work');
$entry->appendChild($email);
$entryResult = $gdata->insertEntry($doc->saveXML(),
'https://www.google.com/m8/feeds/contacts/admin%40dancexd.com/full');
--
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/contacts/community/forum.html