parse-community / parse-php-sdk

The PHP SDK for Parse Platform
https://parseplatform.org/
Other
811 stars 346 forks source link

ParseQuery returns empty arrays or string(59) "Bad Request. Could not decode Response: (4) Syntax error -1" #349

Closed mhadad closed 7 years ago

mhadad commented 7 years ago

Hi,

I'm having an issue with ParseQuery it always returns empty array not even if i use a normal get by objectId.

ParseClient::setCAFile(__DIR__ . '/cacert.pem'); ParseClient::initialize( $app_id, $rest_key, $master_key ); ParseClient::setServerURL('https://parseapi.back4app.com','/'); try { $user = ParseUser::logIn($user, $pass); $cat_query = new ParseQuery("cat"); $cat_query->get("kEVIRIy2xW"); var_dump($cat_query->find(true)); } catch (ParseException $ex) { var_dump($ex->getMessage().' '.$ex->getCode()); }

This query returns string(59) "Bad Request. Could not decode Response: (4) Syntax error -1" while try { $user = ParseUser::logIn($user, $pass); $cat_query = new ParseQuery("cat"); $cat->equalTo("ID", 3); $cat = $cat_query->find(); var_dump($cat_query->find()); } catch (ParseException $ex) { var_dump($ex->getMessage().' '.$ex->getCode()); }

returns an empty array...what am i doing wrong? even the REST API says parse.com has shutdown

flovilmart commented 7 years ago

the response doesn't seem to be in JSON, verify your configuration with back4app, perhaps the server URL is not the right one. What'S the result when you to:

curl -H 'X-Parse-Application-Id: YOUR_APP_ID' -H 'X-Parse-Rest-API-Key: YOUR_REST_KEY' https://parseapi.back4app.com/cat/kEVIRIy2xW

replacing YOUR_APP_ID / YOUR_REST_KEY with your keys.

mhadad commented 7 years ago

Hi,

Thanks alot for your reply. I'm getting {"message":"Not Found","error":{}} though I have cat as a class in our Parse and the objectId exists in that collection

flovilmart commented 7 years ago

that's not a standard parse error, when you run with curl -vvv ... what does it produce? be careful stripping your keys before posting.

mhadad commented 7 years ago

` curl -X GET -vvv --insecure -H "X-Parse-Application-Id: appId" -H "X-Parse-REST-API-Key: restKey" https://parseapi.back4app.com/cat/kEVIRIy2xW

even if I use the --insecure or -k arguments neither with the --cacert it does not work.

flovilmart commented 7 years ago

I'm not sure then you should probably reach back4app support as it doesn't seem to be an issue with the PHP SDK (Curl is not working as expected either)

ianho commented 6 years ago

Line 343 in ParseCurlHttpClient.php Change $headerSize = mb_strlen($this->response) - $match[1]; to $headerSize = mb_strlen($this->response, '8bit') - $match[1];

softmastx commented 5 years ago

Line 343 in ParseCurlHttpClient.php Change $headerSize = mb_strlen($this->response) - $match[1]; to $headerSize = mb_strlen($this->response, '8bit') - $match[1];

This issue has seen after I moved to PHP 7 you save my day!!! Thank youuuuuuu.

coffemate commented 5 years ago

Line 343 in ParseCurlHttpClient.php Change $headerSize = mb_strlen($this->response) - $match[1]; to $headerSize = mb_strlen($this->response, '8bit') - $match[1];

Got same problem,this worked.