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-xOvsSyC83P2lhZRVvvaQLQddaifKO2qmN2KL91eaI";s:18:"oauth_token_secret";s:42:"R4nBLeWhNRXleKsN6H3crubYd2FEmfHFRtLbEh8gos";s:7:"user_id";s:8:"64658798";s:11:"screen_name";s:13:"MyTwitterAccount";}}
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) "146" ["Connection"]=> string(5) "close" } ["body":protected]=> string(146) "�������E˹� ��п��J;80���4(,9��� ��.M��ؖ�"K���H���Q��a|;W����d2��.�Je�-���-y.���3��〺 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