Sample Code - www-getstorify-com/getstorify-offers-php-sdk GitHub Wiki
This is a sample PHP code to help you get started.
Project structure
/myproject
|
+-- GetStorifyOffers
| |
| +-- autoload.php
| |
| +-- GetStorifyOffers.php
| |
| +-- more files and directories
|
+-- index.php
Code
The following code is written inside index.php
file.
<?php
require_once __DIR__ . '/GetStorifyOffers/autoload.php';
// Fill in your credentials here.
define('GETSTORIFY_OFFERS_API_SERVICE_AUTH_APPID', 'your_app_id');
define('GETSTORIFY_OFFERS_API_SERVICE_AUTH_USERID', 'your_user_id');
define('GETSTORIFY_OFFERS_API_SERVICE_AUTH_APPTOKEN', 'your_app_token');
// create object
$GetStorifyOffersObj = new \GetStorifyOffers\GetStorifyOffers(
GETSTORIFY_OFFERS_API_SERVICE_AUTH_APPID,
GETSTORIFY_OFFERS_API_SERVICE_AUTH_USERID,
GETSTORIFY_OFFERS_API_SERVICE_AUTH_APPTOKEN
);
// get access token
$accessTokenResult = $GetStorifyOffersObj->getAccessToken();
if (!isset($accessTokenResult['success'])) {
die('Failed to get access token.');
}
// get user detail
$userResult = $GetStorifyOffersObj->getUserDetail();
if (isset($userResult['success'])) {
echo "UserId: {$userResult['success']['userid']}";
} else if (isset($userResult['error'])) {
echo "Error: {$userResult['message']}";
}