Jump to content

Recommended Posts

Posted

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?

Posted

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

Posted

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

Posted

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

Posted

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

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...