jdolitsky / AppDotNetPHP

PHP library for the App.net Stream API
34 stars 19 forks source link

Return data from createFile() appears to be getting lost. #40

Closed cdn closed 11 years ago

cdn commented 11 years ago

$ok = $app->createFile($file, array('metadata' => 'file.type'); leaves me with nothing in $ok

$ok2 = $app->getLastResponse(); called afterwards clearly shows expected return data with file id and token.

Has anyone else seen this?

cdn commented 11 years ago

More specifically the call to parseHeaders() is returning the data it was fed, such that json_decode() cannot decipher the data.

cdn commented 11 years ago

Return data: HTTP/1.1 100 Continue

HTTP/1.1 200 OK ---8<--

That gap between the HTTP 100 and 200 is throwing off the parsing in parseHeaders()

cdn commented 11 years ago

diff --git a/AppDotNet.php b/AppDotNet.php index 720a0d0..9865d4c 100644 --- a/AppDotNet.php +++ b/AppDotNet.php @@ -303,6 +303,12 @@ class AppDotNet {

            $response = explode("\r\n\r\n",$response,2);
            $headers = $response[0];

           if($headers == 'HTTP/1.1 100 Continue') {
                   $response = explode("\r\n\r\n",$response[1],2);
                   $headers = $response[0];
           }

            if (isset($response[1])) {
                    $content = $response[1];
            }
cdn commented 11 years ago

Will amend my fork and submit another pull request.