fliPoll SDK for PHP
, (*1)
This repository contains PHP code that allows for the easy integration of fliPoll into server-side applications., (*2)
Resources
Getting Started
-
Signup with fliPoll - Before you can use the SDK, you need a fliPoll account with app credentials. To create an account, go to fliPoll and click the Sign Up button in the top right hand corner of the screen.
-
Create a fliPoll app - Once you have a fliPoll account, login and navigate to your App Dashboard to create an app then save off its
app id and app secret to be used later on.
-
Minimum requirements - The PHP SDK requires a system including PHP >= 5.4 compiled with cURL >= 7.20.0.
-
Install the SDK - The PHP SDK can be included either through an installation via Composer or by downloading the SDK zip file from GitHub and including it directly., (*3)
-
Using the SDK - To learn how to use the PHP SDK, the PHP SDK Getting Started Guide is the best resource for information on the design and incorporation of the SDK into an application. For details on the main classes contained within the SDK, see the PHP SDK Reference., (*10)
Examples
Initialization
The following code initializes the PHP SDK with the minimum required options., (*11)
require 'vender/autoload.php';
$fliPoll = \fliPoll\fliPoll([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}'
]);
App Access Token Retrieval
The following code initializes the PHP SDK then retrieves an app access token from the fliPoll servers., (*12)
require 'vender/autoload.php';
$fliPoll = \fliPoll\fliPoll([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}'
]);
try {
// Get an OAuth 2.0 client
$oauth2Client = $fliPoll->getOAuth2Client();
// Retrieve an app access token from the fliPoll servers
$accessToken = $oauth2Client->getAppAccessToken();
// Set an access token with the base class dynamically
$fliPoll->setAccessToken($accessToken);
} catch (\fliPoll\Exceptions\fliPollSdkException $e) {
exit('SDK error occurred: ' . $e->getMessage());
} catch (\fliPoll\Exceptions\fliPollAuthenticationException $e) {
exit('Authentication error occurred: ' . $e->getMessage());
} catch (\Exception $e) {
exit('Error occurred: ' . $e->getMessage());
}
API Request
The following code initializes the PHP SDK with an existing access token then executes an API request and outputs the results., (*13)
require 'vender/autoload.php';
$fliPoll = \fliPoll\fliPoll([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}',
'access_token' => '{access-token}' // Set an access token at initialization
]);
try {
// Execute an API request and retrieve the response
$response = $fliPoll->api('/461');
// Output the results of the API request
var_dump($response->getResults());
} catch (\fliPoll\Exceptions\fliPollSdkException $e) {
exit('SDK error occurred: ' . $e->getMessage());
} catch (\fliPoll\Exceptions\fliPollApiException $e) {
exit('API error occurred: ' . $e->getMessage());
} catch (\Exception $e) {
exit('Error occurred: ' . $e->getMessage());
}
Contributing
We're big proponents of community collaboration so we encourage our users to submit issues for potential bugs as well as proposed features and enhancements., (*14)
To help us better handle issue requests, search the existing issues list first to verify your problem hasn't already been reported. Also, providing the PHP version, OS name and version, and SDK version used when an issue was encountered is recommended., (*15)
License
Please see the license file for more information., (*16)