Thread Starter
Joshua
(@joshuapalinggmailcom)
By the way, it’s working on my localhost – just not on the staging server.
Doing some debugging and print_r’s, it turns out the difference between the staging site and the local site is this:
On the staging site, $this->_oauthToken contains:
“HTTP/1.1 200 OK Content-Language: en Content-Type: application/json Date: Tue, 04 Dec 2012 04:14:39 GMT Server: nginx Vary: Accept-Language, Cookie, Accept-Encoding Content-Length: 367 Connection: keep-alive {“access_token”:”104849973.098c54f.73df46f417e643239e6e79b4ca5916b8″,”user”:{“username”:”flamingopinkau”,”bio”:”Welcome to our Instagram page. Put the kettle on, settle in and stay a while xox”,”website”:”http:\/\/flamingopink.com.au”,”profile_picture”:”http:\/\/images.instagram.com\/profiles\/profile_104849973_75sq_1339942957.jpg”,”full_name”:””,”id”:”104849973″}}”
And on the local site, it contains pretty much the same thing – but only the json array. No “HTTP/1.1 200 OK Content-Language: en Content-Type: application/json Date: Tue, 04 Dec 2012 04:14:39 GMT Server: nginx Vary: Accept-Language, Cookie, Accept-Encoding Content-Length: 367 Connection: keep-alive” at the start of it. Now to figure out why the staging site is getting that additional stuff… any ideas?
Thread Starter
Joshua
(@joshuapalinggmailcom)
OK so it turns out the issue is in CurlHttpClient.php, inside Instagram-PHP-API. Because open_basedir is false, the ‘getResponse’ method calls “curl_redir_exec”, which sets CURLOPT_HEADER to true, so headers are included in the response.
The ‘curl_redir_exec’ method has a line:
list( $header, $data ) = explode( "\r\n", $data, 2 );
which attempts to strip out the headers before finally returning $data, but it doesn’t always work. Sometimes there’s more than one “\r\n” within the header part of the response.
Anyway, basically, it’s the same problem as what’s described here: http://stackoverflow.com/questions/11359276/php-curl-exec-returns-both-http-1-1-100-continue-and-http-1-1-200-ok-separated-b so that’s what I’m using as a solution. Hope that helps if someone else has the same issue.
Thread Starter
Joshua
(@joshuapalinggmailcom)
(just marking this topic as resolved)