techhelper1 Posted June 11, 2013 Report Posted June 11, 2013 Hi everyone, I was curious if any new API calls were added in besides the ones listed for v2 on the main site. I would rather develop a site during the beta stages so I can go live when the final version comes out. Thanks. Quote
Paul Posted June 11, 2013 Report Posted June 11, 2013 Yes, the API is completely new and supports all public model methods, including those of plugins. Please see http://docs.blesta.com/display/dev/API and also http://source-docs.blesta.com/ for the source docs. Quote
Cody Posted June 11, 2013 Report Posted June 11, 2013 More specifically: http://source-docs.blesta.com/package-blesta.app.models.html And of course, as the dev docs mention, all plugin model methods are also callable via the API (though not currently listed in the source docs). Quote
techhelper1 Posted June 12, 2013 Author Report Posted June 12, 2013 Hi again, I have been following the documentation to do remote API calls. How would I be able to do an array for the Users-Add call and others that would need an array at a remote location? Thanks. Quote
Cody Posted June 12, 2013 Report Posted June 12, 2013 Hi again, I have been following the documentation to do remote API calls. How would I be able to do an array for the Users-Add call and others that would need an array at a remote location? Thanks. Use curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($args)); P.S. An SDK has been released that makes API requests much easier, but it only works for version 3.0.0.b4 and newer. Quote
wdfee Posted August 23, 2013 Report Posted August 23, 2013 I'm not able to connect with the API. Using the files from SDK, following steps from your documentation, trying get and post, definitely correct user/key information. message: 401 The authorization details given appear to be invalid. I took your blesta_api.php and blesta_response.php as they are, created a new file and called the API the following way: // of course I got the right informaiton in $api_url, $api_username and $api_key $blesta_api = new BlestaApi($api_url, $api_username, $api_key); // The Model to request, I tried here "users" as well $model = "clients"; // The method to request, I tried here "get" as well $method = "getByUserId"; // $format = "json" is set by your class // All parameters to send, 3 is my test client $params = array('user_id'=>3); // API request $response = $blesta_api->get($model, $method, $params); return $response; I took a look into the blesta core files api.php and api_keys.php and did some testing. It seems that the getAuthMode() doesn't return a mode, both conditions return false. All requested $_SERVER variables return null. I tested this by commenting out the condition for basic to force this mode and entering the correct key and url in line 2285/286 - then it works. Quote
wdfee Posted August 23, 2013 Report Posted August 23, 2013 Blesta 3.0.1 (tried on 3.0.0 before, too) PHP-Version: 5.3.2-1ubuntu4.20 Quote
wdfee Posted August 23, 2013 Report Posted August 23, 2013 Ok, I think I found the cause: My Server API is CGI/FCGI, not Apache 2.0 Handler. http://stackoverflow.com/questions/3663520/php-auth-user-not-set And inspired by this thread: https://github.com/symfony/symfony/issues/1813 I added this to my .htaccess: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ api.php [QSA,L] </IfModule> now it works!! :-) Michael 1 Quote
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.