ty0716 Posted September 28, 2015 Report Posted September 28, 2015 error: why this? <?php require_once "../blesta/blesta_api.php"; $user = "resller"; $key = "**********"; $url = "http://*********/api/"; $api = BlestaApi::getIns($url, $user, $key); $json='{"action":"signup","first_name":"\u9676","last_name":"\u96e8","company":"\u6c49\u53e3\u5b66\u9662","address1":"\u6c5f\u590f\u533a\u6587\u5316\u5927\u9053299\u53f7","address2":"16703","city":"\u6b66\u6c49\u5e02","country":"CN","state":"13","zip":"430070","numbers":[{"type":"phone","location":"work","number":"15527474844"},{"type":"fax","location":"work","number":"13396009700"}],"email":"hkxy99@163.com","tax_id":"95599","custom_field1":"424460883","username_type":"email","username":"","new_password":"qaz12345","confirm_password":"qaz12345","client_group_id":"1","settings":{"username_type":"email","tax_id":"95599","default_currency":null,"language":"en_us"},"custom":{"1":"424460883"}}'; $vars=json_decode($json,true); $response=$api->get('clients','create',$vars); print_r($response->response()); print_r($response->errors()); data: json->array: {"action":"signup","first_name":"\u9676","last_name":"\u96e8","company":"\u6c49\u53e3\u5b66\u9662","address1":"\u6c5f\u590f\u533a\u6587\u5316\u5927\u9053299\u53f7","address2":"16703","city":"\u6b66\u6c49\u5e02","country":"CN","state":"13","zip":"430070","numbers":[{"type":"phone","location":"work","number":"15527474844"},{"type":"fax","location":"work","number":"13396009700"}],"email":"hkxy99@163.com","tax_id":"95599","custom_field1":"424460883","username_type":"email","username":"","new_password":"qaz12345","confirm_password":"qaz12345","client_group_id":"1","settings":{"username_type":"email","tax_id":"95599","default_currency":null,"language":"en_us"},"custom":{"1":"424460883"}} Error: Internal error: Failed to retrieve the default valuestdClass Object ( [error] => stdClass Object ( [message] => An unexpected error occured. [response] => Internal error: Failed to retrieve the default value ) ) Quote
0 serge Posted September 28, 2015 Report Posted September 28, 2015 It's was not in same contex but I found API can not work if your are not in HTTPS at both side (client and server) with valid SSL certificates (not being auto signed) Quote
0 Cody Posted September 29, 2015 Report Posted September 29, 2015 You should be using $api->post('clients', 'create', $vars); But aside from that, the 'Failed to retrieve the default value' error is the result of a bug in ionCube. I've never seen it happen in a non-encoding file, though. So it must be calling something in AppModel which is encoded. I hate ionCube so much. Blesta Addons and Michael 2 Quote
0 ty0716 Posted September 30, 2015 Author Report Posted September 30, 2015 You should be using $api->post('clients', 'create', $vars); But aside from that, the 'Failed to retrieve the default value' error is the result of a bug in ionCube. I've never seen it happen in a non-encoding file, though. So it must be calling something in AppModel which is encoded. I hate ionCube so much. thank you ,but use post method still return same error. I found this can be success in order plugin,signup :$this->clients->create($vars); There are other ways to achieve registration by API, unless post data to a custom plugin then register? Quote
0 ty0716 Posted September 30, 2015 Author Report Posted September 30, 2015 You should be using $api->post('clients', 'create', $vars); But aside from that, the 'Failed to retrieve the default value' error is the result of a bug in ionCube. I've never seen it happen in a non-encoding file, though. So it must be calling something in AppModel which is encoded. I hate ionCube so much. CORE-1232 http://dev.blesta.com/browse/CORE-1232 Quote
0 WebhostingNZ.com Posted October 20, 2017 Report Posted October 20, 2017 Necro thread sorry. Had this same issue and found this thread so will post the fix here which I found by following the CORE-1232. As stated in CORE-1232 "Important to note that this issue does not happen if you specify all parameters to a method". The fix simply to make sure you pass all parameters, for example. Does not work:$response = $api->post("encryption", "systemEncrypt", array('value' => "my text")); Does work: $response = $api->post("encryption", "systemEncrypt", array('value' => "my text", 'key' => "f059...[snip]...895f", 'iv' => "f059b0f...[snip]...80fa3895f")); For this example, you get your encryption key used in the second two prams from config/blesta.php and put it in which is what it should default to anyway. I suggest an update to the API documentation to cover that in some instances you have to pass all parameters. On the below API doc, the first two examples should be updated as they don't currently work as they are (or don't for me):https://docs.blesta.com/display/dev/API Thanks. Blesta Addons 1 Quote
Question
ty0716
error:
why this?
data:
json->array:
Error:
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.