PHP Lib – THttpClient: Could not read xx bytes from sandbox.evernote.com:443//edam/user
1#.
I’m having problem instantiating evernote cloud API client. I get the following exception dump (original lib and root path are replaced)
Uncaught TTransportException: exception ‘TTransportException’ with message ‘THttpClient: Could not read 1013476926 bytes from sandbox.evernote.com:443//edam/user’ in /php_lib_path/evernote/transport/THttpClient.php:156
Stack trace:
#0 /php_lib_path/evernote/transport/TTransport.php(87): THttpClient->read(1013476926)
#1 /php_lib_path/evernote/protocol/TBinaryProtocol.php(207): TTransport->readAll(1013478509)
#2 /php_lib_path/evernote/packages/UserStore/UserStore.php(75): TBinaryProtocol->readMessageBegin(NULL, 0, 0)
#3 /php_lib_path/evernote/packages/UserStore/UserStore.php(42): EDAM\UserStore\UserStoreClient->recv_checkVersion()
#4 [internal function]: EDAM\UserStore\UserStoreClient->checkVersion('Evernote EDAMTe...', 1, 25)
#5 /php_lib_path/evernote/Evernote/Client.php(142): ReflectionMethod->invokeArgs(Object(EDAM\UserStore\UserStoreClient), Array)
#6 /wwwroot/evernote/EDAMTest.php(66): Evernote\Store->__call('checkVersion', Array)
#7 /wwwroot/evernote/EDAMTest.php(66): Evernote\Store->checkVersion('Evernote EDAMTe...', 1, 25)
#8 {main}
I have tested that the script works on my local environment. And in this testing environment, I have double checked that
1- OpenSSL is open and PHP support is enabled and supported
2- Trying to connect to evernote production environment (with sandbox => false) also failed
解决问题:
3#.
Hi, it appears that my production is running PHP 5.3 while my local environment runs 5.4, hence the user_agent could not be set correctly. Adding
ini_set("user_agent", "PHP/THttpClient\r\nAccept: application/x-thrift\r\nContent-Type: application/x-thrift");
solves the problem