I use Zend Oauth to connect my app to Twitter as described here:
It works perfectly saving the Twitter Request Token and the Twitter
Access Token in the session using serialize and unserialize like this

1: $consumer = new Zend_Oauth_Consumer($config);
2: $token = $consumer->getRequestToken();
3: $_SESSION['TWITTER_REQUEST_TOKEN'] = serialize($token); //write
Request Token
4: $consumer = new Zend_Oauth_Consumer($config);
5: $token = $consumer->getAccessToken($_GET,
6: $_SESSION['TWITTER_ACCESS_TOKEN'] = serialize($token); //write
Access Token
7: $token = unserialize($_SESSION['TWITTER_ACCESS_TOKEN']);
8: $client = $token->getHttpClient($configuration);

Now I want to save the Access Token in my mySQL database after line 6.
The problem is that as soon as I do this the entry in the db contains
weird characters like this:


which leads to a notice (Error at offset 30 of 280 bytes)  in line 7
and and fatal error on line 8 because $token is a non-object.
So I tried to figure out the error and already posted the problem in
the Zend forum but nobody could help me...
My best guess is that it's an encoding error. The database and all my
documents are encoded corretly in utf-8 though and I never had
problems like this before...
A var_dump($token) in line 3 shows me that there are already crytpic
chars there. Here's an extract:

"Accept-Encoding" ["Content-encoding"]=>  string(4) "gzip" ["Content-
length"]=>  string(3) "149" ["Connection"]=>  string(5) "close" }
["body":protected]=>  string(149) " � ������ E˻ �0 �пqnc��...@�1>X�R
\�R� i{��F�z  �~P�A��#���ɡٲ���ƒ&v��i~G s��A3�]�� � ��x�� R �<�Y-
���Jok4��v�����g���#-�_VҘV�Q(t��[���g� & g}����" }
["_httpUtility":protected]=>  object(Zend_Oauth_Http_Utility)#89 (0)

Is the content-encoding gzip the problem? Or is the problem caused by
Zend and the getRequestToken() method?
Any help is highly appreciated.
Thanks in advance

Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 

Reply via email to