Support Topics Documentation Slack YouTube Blog

PHP SDK REST Error 2002 : Version is disabled or provided wrong application info


(Fatih Batal) #1

Hi,

I’m not deleting my question, simply for future reference.

But the problem was in fact with the documentation, just a small mistake in https://backendless.com/documentation/data/php/data_saving_data_objects.htm as

Backendless::initApp('YOUR-REST-SECRET-KEY', 'YOUR-APPLICATION-ID', 'v1');

where it should be

Backendless::initApp('YOUR-APPLICATION-ID', 'YOUR-REST-SECRET-KEY', 'v1');

Best,

~ Fatih

•••
Original Question / Problem:

I already checked other threads related to this issue but they didn’t help.
Now, following code works as expected :


<?php






header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1
header("Pragma: no-cache"); // HTTP 1.0
header("Expires: 0"); // Proxies






$url = 'https://api.backendless.com/v1/data/Users';



$headers = array(
"Content-Type:application/json",
"application-id:" . kpBACKENDLESS_APP_ID,
"secret-key:" . kpBACKENDLESS_REST_KEY
);






$ch = curl_init();



curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);



$result = curl_exec($ch);



curl_close($ch);



var_dump( $result );






?>

Yet, this one throws the error in the subject line :


<?php



header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1
header("Pragma: no-cache"); // HTTP 1.0
header("Expires: 0"); // Proxies






require_once (kpPATH_TO_LIBS . "/Backendless/backendless/autoload.php");



use backendless\Backendless;



try {



Backendless::initApp( kpBACKENDLESS_REST_KEY, kpBACKENDLESS_APP_ID, kpBACKENDLESS_APP_VERSION );



} catch (Exception $e) {



echo $e->getMessage();
// Prints Error 2002 and its description



}



?>

Just guide me to the right direction to find out the source of problem, where should I look, what should I debug?
Thanks,
~ Fatih


(Anton Govorushkin) #2

If I understood you correctly the code you’ve attached below doesn’t work, right?
Or you’ve eventually managed to fix the issue by yourself?

Regards Anton


(Fatih Batal) #3

Hi Anton,

It wasn’t working because initApp’s parameters were in wrong order.

I’ve copy-pasted that code from the documentation at https://backendless.com/documentation/data/php/data_saving_data_objects.htm
and the sample in that page wasn’t correct.

Once I’ve replaced APP_ID and REST_KEY, it got solved.
You might want to update that sample in your documentation; whenever you got time.

Best,

~ Fatih


(Anton Govorushkin) #4

Thanks a lot, Fatih

We’ll update the documentation as soon as possible.

Regards Anton


(Mark Piller) #5

Hi Faith,

The doc has been updated. Thank you for reporting it to us.

Cheers,
Mark