Hi,
I use Zend Oauth to connect my app to Twitter as described here:
http://framework.zend.com/manual/en/zend.oauth.introduction.html
It works perfectly saving the Twitter Request Token and the Twitter
Access Token in the session using serialize and unserialize like this
(abbreviated):

1: $consumer = new Zend_Oauth_Consumer($config);
2: $token = $consumer->getRequestToken();
3: $_SESSION['TWITTER_REQUEST_TOKEN'] = serialize($token); //write
Request Token
               ...and...
4: $consumer = new Zend_Oauth_Consumer($config);
5: $token = $consumer->getAccessToken($_GET,
unserialize($_SESSION['TWITTER_REQUEST_TOKEN']));
6: $_SESSION['TWITTER_ACCESS_TOKEN'] = serialize($token); //write
Access Token
               ...and...
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:

O:23:"Zend_Oauth_Token_Access"?:{s:10:"�*�_params";a:4:{s:
11:"oauth_token";s:50:"64658798-xOvsSyC8dP2lhZRVvQdcgifKmN2KL91eaI";s:
18:"oauth_token_secret";s:42:"R4nBLeQhNRXleKsN6HruBYd2FEmfHFKtLbgos";s:
7:"user_id";s:8:"64658798";s:11:"screen_name";s:13:"MyAppName";}}

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: 
http://groups.google.com/group/twitter-development-talk?hl=en

Reply via email to