API and Activity Arguments

Hey

When I make a get request with only the first argument ("/activity/") it works as expected. But if I add an array as the second argument, the _request function in Client.php throws an exception, but the exception is empty with no info. Here's my code:

 

$data = array(
        'path'     => '/Public Downloads/Syntorial-Demo-Installer.msi',
    );

try
{
    $response = $client->get("/activity/", $data);
    echo "pages: " . $response['pages'];
}

catch(Exception $e)
{
    echo 'Message : ' . $e->getMessage();
}

This happens no matter what I fill the $data array with. I've tried 'page', 'limit', etc. Always the same empty exception. Any ideas?

3replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • 1. What is the name of the exception? The client has specific exceptions for a two kinds of errors.

    2. Also, try echoing the $response right after the call to $client->get().

    3. If that doesn't give you any more information do like we did here:

    http://smartfile.forumbee.com/t/x0wlc

    Bypass the get function and use the doRequest() function. Then, echo the $response right after that.

    $response = $client->doRequest('/activity/', 'get', $data);
    echo $response;
    
    Reply Like
  • 1. The exception is Service_SmartFile_ResponseException

    2/3. $response is empty.

    Bypassing the get, also results in an empty $response. 

    I've tried echoing the $response in the get( method, as well as in a few of the other methods called, but they all come back empty.

    I am getting the following php error:

    
    Deprecated: Function split() is deprecated in 
    /home5/syntoria/Smartfile/Client.php on line 
    212
    
    
    Notice: Undefined offset: 2 in 
    /home5/syntoria/Smartfile/Client.php on line 
    212
    
    
    Notice: Undefined offset: 1 in 
    /home5/syntoria/Smartfile/Client.php on line 
    212
    

    Line 212 is:

    list($ignored, $http_status, $ignored) = split(' ', $headers);​
    

    Does this php error clue you into what's going wrong in Client.php?

    Reply Like
  • The php errors do help. Check of the php docs:

    http://us2.php.net/split

    You can see that split() is deprecated as of php 5.3. Assuming you are using php 5.3 or newer.

    Replace it with preg_split is also recommended in the docs:
    http://us2.php.net/split#refsect1-function.split-notes
    http://us2.php.net/manual/en/function.preg-split.php

    Given that we are splitting on a space, changing to preg should work without issue.

    In the future, Googling your php errors will save you time waiting for a response.

    Reply Like
Like Follow
  • 5 yrs agoLast active
  • 3Replies
  • 872Views
  • 2 Following