Cronycle php sdk provides basic functionality for communication with Cronycle API.
Cronycle PHP SDK library is aimed to be installed via composer by adding the following lines into you composer.json file.
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/cronycle/cronycle-php-sdk"
}
],
"require": {
"cronycle/cronycle-php-sdk": "dev-master"
}
}
When composer dependencies installed just require autoload file and you are ready to use SDK!
require_once __DIR__.'/vendor/autoload.php' $API = new \Cronycle\Api(); $accounts = $API->logIn( 'email', 'password' ); $token = $accounts[0]['auth_token']; // choose first from multiple accounts $API->useAccount( $token ); ...
Once you have authenticated user, you can keep token in the current session and initialize API at any time as follows:
require_once __DIR__.'/vendor/autoload.php' $API = new \Cronycle\Api( $token ); ...
Every API request (except log in) requires Authorization header with a valid token to be passed. Otherwise handler will throw an exception with an error message and 403 status code.
###Log in:
Parameters:
email - string, requried, user account email
password - string, requried, user account password
Response:
$accountsDetails - array
$accounts = $API->logIn( 'email', 'password' );
###Sign in with Google - will trigger redirect to social provider sign in and return response to callback url:
Parameters:
callback - string, requried, callback url
Response:
redirect
$API->logInWithGoogle( 'callback' );
###Sign in with Twitter - will trigger redirect to social provider sign in and return response to callback url:
Parameters:
callback - string, requried, callback url
Response:
redirect
$API->logInWithTwitter( 'callback' );
###Log out:
Parameters:
no parameters
Response:
no response
$API->logOut();
###Getting boards list:
Parameters:
no parameters
Response:
boardList - array
$boards = $API->getBoardsList();
###Getting single board details:
Parameters:
boarId - integer, required, board id
Response:
boardDetails - array
$board = $API->getBoardDetails( $boardId );
###Getting board articles list:
Parameters:
boarId - integer, required, board id
params - array, optional, list of extra parameters for a call
- per_page - Number of links to return per page, if a value of 0 is provided then all links for the topic_board are returned Example: 25. Default: 25.
- page - Page number to return, and only takes effect if the per_page value is greater than 0 Example: 1. Default: 1.
- max_timestamp - Timestamp to limit the latest link (<= max_timestamp) (based on the addition to the topic board)
- min_timestamp - Timestamp to limit the earliest link (=> min_timestamp) (based on the addition to the topic board)
- before_timestamp - TTimestamp to limit the list of the links similar to max_timestamp, except that links which match the timestamp are not returned (< before_timestamp) (based on the addition to the topic board)
- include_links - Indicates whether the links should be loaded and included or not Default: false.
- clean_links - Will parse out img, strong, br tags as well as blank p, figure, a tags. Note caching is disabled if this parameter is used.
- clean_description - Will clean all html tags from article description. Note caching is disabled if this parameter is used.
- search_text - Searches text on article tiles, note tiles, and titles of file tiles
- contributor_ids - Filter by users who created a tile, must be a comma separated list of user ids (eg. 1,2,3)
- tags - Filter by tags attached to the tile, must be a comma separated list of tags (eg. red,blue,green)
- sort_by - Sorting and additional filtering. Must be one of (published_date, notes_only, articles_only, comment_count, engagement)
- last_visited - If this is provided AND it's more recent than the existing last_visited date for this user, then the users last_visited date is updated. If this is provided AND it's less recent than the existing last_visited date for this user, then the users last_visited date is not updated. If the value is not provided then the last_visited is set to the current time. In this way the last_visited time can only be advanced. Currently the last_visited value does not affect any tile attributes, but does change the new_items counts on the topic_board index endpoint
Response:
boardArticlesList - array
$articles = $API->getBoardArticles( $boardId, $params );
You can use demonstration account details below to start working with the SDK:
E-mail: demosdk@cronycle.com
Password: lifeafterboards2016
https://github.com/cronycle/cronycle-php-sdk-demo
- Cronycle Board Exporter (https://github.com/cronycle/exporter)