I'm developping a google app using php. I need to consume REST service from Podio using the Podio-php API. But it uses cURL and I know it's not allowwed on GAE. So I tried tweaking the podio-php lib to use file_get_contents through a curl Emulator. Works fine locally, but when I deploy it, nothing works. I get this error message:
Warning: file_get_contents(https://api.podio.com:443/oauth/token): failed to open stream: Invalid headers. Must be a string. in /base/data/home/apps/s~wt-project1/9.374066902612513343/static/curlEmulator.php on line 167
And then, I get no responses and it breaks all the app.
Anyone has an idea from where the problems comes?
Here is the call:
$options = array(
"ssl"=>array(
"allow_self_signed"=>true,
"verify_peer"=>false,
),
'http' => array(
'method' => $method,
'header' => $this->getValue(CURLOPT_HTTPHEADER),
'content' => $content
)
);
$context = stream_context_create($options);
file_get_contents($this->CURLOPT_URL, false, $context);
Thanks!
I had the same problem on Google App Engine calling an HTTPS API.
I figured out that the problem was the headers format.
I switched from an array to a raw string as followed :
Before :
After:
That solved all my problems.
Hope this will help.
file_get_contents
to my knowledge does not support HTTPS, as such it will see the handshake as invalid headers.I'm unaware of what alternatives are available in GAE I'm afraid, but you should either look for a supported OAUTH library, or an alternative to file_get_contents that support HTTPS connections.
I'd suggest using the below code to find out whether or not HTTPS wrappers are available to you or not.
Reference: above code referenced from this question