Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 401

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 401

maykino
Hi everyone, I've managed to authenticate my code with oAuth but when I try to pull the list of contacts or add a contact to the domain I get the following error:

Hello Mike Smith (admin@******.com)

Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 401 <HTML> <HEAD> <TITLE>Authorization required</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> 

Authorization required

 

Error 401

 </BODY> </HTML> ' in /home/stingeri/public_html/helloworld/Zend/Gdata/App.php:708 Stack trace: #0 /home/stingeri/public_html/helloworld/Zend/Gdata.php(221): Zend_Gdata_App->performHttpRequest('GET', 'http://www.goog...', Array, NULL, NULL, NULL) #1 /home/stingeri/public_html/helloworld/Zend/Gdata/App.php(874): Zend_Gdata->performHttpRequest('GET', 'http://www.goog...', Array) #2 /home/stingeri/public_html/helloworld/Zend/Gdata/App.php(762): Zend_Gdata_App->get('http://www.goog...', NULL) #3 /home/stingeri/public_html/helloworld/Zend/Gdata/App.php(205): Zend_Gdata_App->importUrl('http://www.goog...', 'Zend_Gdata_Feed', NULL) #4 /home/stingeri/public_html/helloworld/Zend/Gdata.php(162): Zend_Gdata_App->getFeed('http://www.goog...', 'Zend_Gdata_Feed') #5 /home/sting in /home/stingeri/public_html/helloworld/Zend/Gdata/App.php on line 708


What do I do wrong?

This is my code:

require_once 'common.php';
require_once 'Zend/Loader.php';
require_once 'Zend/Oauth/Consumer.php';
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_Feed');
$options = array(
    'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
    'version' => '1.0',
    'signatureMethod' => 'HMAC-SHA1',
    'consumerKey' => $CONSUMER_KEY,
    'consumerSecret' => $CONSUMER_SECRET
);
;
$consumer = new Zend_Oauth_Consumer($options);
$token = new Zend_Oauth_Token_Access();
$httpClient = $token->getHttpClient($options);

$gdata = new Zend_Gdata($httpClient);
$gdata->setMajorProtocolVersion(3);      
$gdata->getHttpClient()->setRequestScheme(Zend_Oauth::REQUEST_SCHEME_QUERYSTRING);
$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/default/full');
print_r($query);
$query->setMaxResults(1000000);
$feed = $gdata->getFeed($query);


Thank you
M.
Reply | Threaded
Open this post in threaded view
|

Re: Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 401

maykino
Anyone? It looks like the error shows up only when I try to access the feed:

$feed = $gdata->getFeed($query);

Reply | Threaded
Open this post in threaded view
|

Re: Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 401

Marco Pivetta
Well, it is a 401 HTTP status code, which means "unauthorized"...
I see you have created an OAuth consumer, but you're not using it...
Marco Pivetta
http://twitter.com/Ocramius
http://marco-pivetta.com



On 28 June 2011 16:25, maykino <[hidden email]> wrote:

> Anyone? It looks like the error shows up only when I try to access the
> feed:
>
> $feed = $gdata->getFeed($query);
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/Fatal-error-Uncaught-exception-Zend-Gdata-App-HttpException-with-message-Expected-response-code-200-1-tp3628849p3630499.html
> Sent from the Zend gdata mailing list archive at Nabble.com.
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 401

maykino
Hi Marco, thank you for your response. I used almost identical code to pull all entries from Calendar API and I didn't get any errors. Do you have an idea how the code should look like to work properly?


Thanks again
M.
Reply | Threaded
Open this post in threaded view
|

Re: Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 401

mattymcfatty
This might help you get started out in the right direction.  I got this error after a captcha request error.  I found this to be a little helpful with the captcha, but not necessarily helpful in fixing the 401 error. http://framework.zend.com/manual/en/zend.gdata.clientlogin.html

I will post back if I find out more...
Reply | Threaded
Open this post in threaded view
|

Re: Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 401

mattymcfatty
Easy fix for me. The password was wrong. So I could not get authenticated.