Unengage SDK for PHP
This repository contains the open source PHP SDK that allows you to access the Unengage API from your PHP app., (*1)
Installation
The Unengage SDK can be installed with Composer. Run this command:, (*2)
composer require thoughtchimp/unengage-api-wrapper
Usage
Note: This version of the Unengage SDK for PHP requires PHP 5.5 or greater., (*3)
Instantiating SDK
use Unengage\API;
$api = API('Pass api_key here');
Get all streams
$streams = $api->streams();
Get stream by ID
$stream = $api->stream('Pass stream id here');
Create stream
$stream = $api->createStream('Stream name', 'Stream description');
Update particular stream by ID
$stream = $api->updateStream('STREAM_ID', 'Stream name updated', [
'description' => 'This is the updated description'
]);
Delete stream by ID
$response = $api->deleteStream('STREAM_ID');
Get stream social posts by passing stream id
$posts = $api->streamSocialPosts('STREAM_ID', [
'tags' => 'social, digital'
]);
Get stream social post preview by passing stream id, platform & post_url
$post = $api->streamSocialPostPreview('STREAM_ID', 'platform goest here ex: twitter', 'post_url goes here ex: twitter post url');
Create stream social post by passing stream id, platform & post_url
$post = $api->streamSocialPostCreate('STREAM_ID', 'platform goest here ex: twitter', 'post_url goes here ex: twitter post url', [
'tags' => 'social, digital',
'is_pin' => true,
'is_sponsored'=> false,
'status' => 'published'
]);
Update social posts of a stream by passing post ids
$response = $api->updateStreamSocialPosts('STREAM_ID', ['post_id_1','post_id_2'], [
'is_sponsored' => true,
'tags' => 'funny, hilarious',
'status' => 'draft'
]);
Delete stream by ID
$response = $api->deleteStreamSocialPosts('STREAM_ID', ['post_id_1', 'post_id_2', 'post_id_3']);
Pin a particular social post of a particular stream
$response = $api->pinStreamSocialPost('STREAM_ID', 'POST_ID');
Get list of all social feeds of a particular stream
$feeds = $api->streamSocialFeeds('STREAM_ID');
Create social feed under a particular stream
$feed = $api->createStreamSocialFeed('STREAM_ID', '@thoughtchimp', 'twitter', [
'status' => 'published',
'tags' => 'entertainment, video service, fun',
'exclude.mentions'=> true,
'exclude.retweets'=> false,
'exclude.replies' => true,
'filters.all' => 'entertainment',
'filters.any' => 'funny, hilarious, enjoy',
'filters.none' => 'negative',
'is_realtime' => false
]);
Get a particular social feed by ID
$feed = $api->streamSocialFeed('STREAM_ID', 'FEED_ID');
Update stream social feed
$feed = $api->updateStreamSocialFeed('STREAM_ID', 'POST_ID', [
'status' => 'draft',
'tags' => 'social, digital, media',
'exclude.mentions'=> false,
'exclude.retweets'=> false,
'exclude.replies' => true,
'filters.all' => 'entertainment',
'filters.any' => 'funny, hilarious, enjoy',
'filters.none' => 'negative',
'is_realtime' => true
]);
Delete social feed
$response = $api->deleteStreamSocialFeed('STREAM_ID', 'FEED_ID');
Refresh stream social feed (Prioritizing feed)
$response = $api->refreshStreamSocialFeed('STREAM_ID', 'FEED_ID');
Get all social accounts of a particular stream
$accounts = $api->streamSocialAccounts('STREAM_ID');
Create stream social account
$api->createStreamSocialAccount('STREAM_ID', NAME, USERNAME, UID, PLATFORM, TOKEN, [array of properties]);
$account = $api->createStreamSocialAccount('STREAM_ID', 'Rohit Khatri', 'rohit49khatri', '39478934', 'twitter', '39478skhf3948shkjfsdf', [
'secret' => 'Here secret goes if provided by the platform example twitter',
'refresh_token' => 'Here secret goes if provided by the platform example youtube'
]);
Complete documentation is available here., (*4)