flipoll / php-sdk
fliPoll SDK for PHP
Requires
- php: ^5.4|^7.0
This package is not auto-updated.
Last update: 2025-06-08 06:44:39 UTC
README
This repository contains PHP code that allows for the easy integration of fliPoll into server-side applications.
Resources
- REST API Overview - The purpose and basic functionality of the REST API
- API Getting Started Guide - How to start using the REST API
- REST API Reference - List of all REST API resources
- PHP SDK Overview - The design and basics of the PHP SDK
- PHP SDK Getting Started Guide - How to start using the PHP SDK
- PHP SDK Reference - List of main PHP SDK classes
- API SDKs - All available REST API SDKs
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
andapp 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.
-
Installing via Composer
-
Install Composer via the command line.
$ curl -sS https://getcomposer.org/installer | php
-
Run the Composer command to install the latest stable version of the SDK via the command line.
$ php composer.phar require flipoll/php-sdk
-
Require Composer's autoloader at the top of the PHP file(s) that will use the SDK.
require 'vender/autoload.php';
-
-
Installing via Zip
-
Download the zip file from GitHub.
-
Copy the src directory into the codebase that will use the SDK.
-
Require the fliPoll autoloader at the top of the PHP file(s) that will use the SDK.
require '/path/to/fliPoll/autoload.php';
-
-
-
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.
Examples
Initialization
The following code initializes the PHP SDK with the minimum required options.
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.
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.
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.
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.
License
Please see the license file for more information.