Jump to content

mesino

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by mesino

  1. Hi.

    I am trying to use PHP-Curl to create a ticket via Blesta API and have a few queries:

    As per my understanding, in order to create a new ticket you need two HTTP calls. One for add() and another for addReply(). Is that correct?

    Secondly is there is working example of posting files along with the call to create a ticket. The parameter's explanation for it is a bit vague:

    * @param array $files A list of file attachments that matches the global FILES array

    Firstly I am not sure what should the structure of $files should be. Furthermore when I went through the code it appeared that the addReply method will only make use of '$files' array posted by API instead of $_FILES (only which can have the local 'tmp_name' of uploaded files).

    $this->Upload->setFiles($files, false);

    but $files is supplied remotely. I hope I am making some sense here.

    Thanks.

  2. Hi @Tyson

    I had tried NULL but that also results in the same error:
     

    <?php
    require_once "blesta_api.php";
    
    $user = "{API_USER}";
    $key = "{API_USER}";
    $url = "{API_URL}";
    
    $api = new BlestaApi($url, $user, $key);
    $response = $api->post("encryption", "systemEncrypt", array('value' => 'my text', 'key' => NULL, 'iv' => NULL));
    
    print_r($response->response());
    print_r($response->errors());
    exit;
    ?>

    Output:
     

    Internal error: Failed to retrieve the default value
    
    stdClass Object
    (
        [error] => stdClass Object
            (
                [message] => An unexpected error occured.
                [response] => Internal error: Failed to retrieve the default value
            )
    
    )

     

  3. After some hit & trial and following hints on the API doc page, I realized that supplying values of optional arguments suppresses the error:

    $response = $api->post("encryption", "systemEncrypt", array('value' => 'my text', 'key' => 'my key', 'iv' => 'my iv'));

    works. Even blank values work:

    $response = $api->post("encryption", "systemEncrypt", array('value' => 'my text', 'key' => '', 'iv' => ''));

    As per the API and class docs, without the optional arguments, Blesta should encrypt/decrypt using the Blesta.system_key. But omitting these arguments results in an error as shown in the original post. Copy-pasting the system_key from config/blesta.php into 'key' and 'iv' values solves it for me and produces the desired result but this is far from ideal.

  4. Hi.

    For some custom integration of Blesta, I have been trying the API examples listed here to make myself familiar with the API:

    https://docs.blesta.com/display/dev/API

    While:

    $response = $api->get("users", "get", array('user_id' => 1));

    gives expected results, for some reason:

    $response = $api->post("encryption", "systemEncrypt", array('value' => "my text"));

    fails with:

    Class Object
    (
        [error] => stdClass Object
            (
                [message] => An unexpected error occured.
                [response] => Internal error: Failed to retrieve the default value
            )
    )

    Will really appreciate some pointers. Thanks in advance.

×
×
  • Create New...