serge Posted June 14, 2015 Report Posted June 14, 2015 For a custom php script on same server as Blesta, but not within Blesta, I would like to decrypt an encrypted custom client field. So my script will get the encrypted value from a database query, but after that, how to decrypt the field?
serge Posted June 14, 2015 Author Report Posted June 14, 2015 documentation give this php code example: <?php require_once "blesta_api.php"; $user = "username"; $key = "key"; $url = "https://yourdomain.com/installpath/api/"; $api = new BlestaApi($url, $user, $key); $response = $api->get("users", "get", array('user_id' => 1)); print_r($response->response()); print_r($response->errors()); ?> but I do not understand where is this file: blesta_api.php
Nelsa Posted June 14, 2015 Report Posted June 14, 2015 On 6/14/2015 at 6:13 PM, serge said: documentation give this php code example: <?php require_once "blesta_api.php"; $user = "username"; $key = "key"; $url = "https://yourdomain.com/installpath/api/"; $api = new BlestaApi($url, $user, $key); $response = $api->get("users", "get", array('user_id' => 1)); print_r($response->response()); print_r($response->errors()); ?> but I do not understand where is this file: blesta_api.php It will be there after you download SDK API and put it in install dir ,https://github.com/phillipsdata/blesta_sdk serge 1
serge Posted June 14, 2015 Author Report Posted June 14, 2015 yes, I just figured I suppose now it's connecting with API, I I do have this error in my webserver log: [Sun Jun 14 18:31:41 2015] [error] [client 108.161.128.170] user apitest not found: /index.php/api/encryption/systemDecrypt.json and here is my code to connect with API <?php require_once "blesta_api.php"; require_once "blesta_response.php"; $user = "apitest"; $key = "xxxxxxxxxxxxxxxxxx"; $url = "http://dev-bill.netpublica.com/index.php/api/"; $api = new BlestaApi($url, $user, $key); $response = $api->post("encryption", "systemDecrypt", array('value' => "GzJ9GD+TuG21ChSb4Dl0WzLpW+h8SiYcexW17UiwMJ8=")); print_r($response->response()); print_r($response->errors()); ?> But in blesta the API user exist with it's api key, so, I do not understand
serge Posted June 15, 2015 Author Report Posted June 15, 2015 this error is printed : stdClass Object ( [user] => stdClass Object ( [valid] => The API user or key appears to be invalid. ) ) but my API user & key seem good, I also tried other user/key I created, but all give above error
serge Posted June 15, 2015 Author Report Posted June 15, 2015 ok my dev server has no SSL cerrtificate, so the error I had: "The API user or key appears to be invalid." was just the generic error, But when trying on my live server that do have SSL certificate at blesta, the API request given fine the decrypted string
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now