PHP code example of thoughtchimp / unengage-api-wrapper

1. Go to this page and download the library: Download thoughtchimp/unengage-api-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

thoughtchimp / unengage-api-wrapper example snippets


use Unengage\API;

$api = API('Pass api_key here');

$streams = $api->streams();

$stream = $api->stream('Pass stream id here');

$stream = $api->createStream('Stream name', 'Stream description');

$stream = $api->updateStream('STREAM_ID', 'Stream name updated', [
  'description' => 'This is the updated description'
]);

$response = $api->deleteStream('STREAM_ID');

$posts = $api->streamSocialPosts('STREAM_ID', [
  'tags' => 'social, digital'
]);

$post = $api->streamSocialPostPreview('STREAM_ID', 'platform goest here ex: twitter', 'post_url goes here ex: twitter 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'
]);

$response = $api->updateStreamSocialPosts('STREAM_ID', ['post_id_1','post_id_2'], [
  'is_sponsored'  => true,
  'tags'          => 'funny, hilarious',
  'status'        => 'draft'
]);

$response = $api->deleteStreamSocialPosts('STREAM_ID', ['post_id_1', 'post_id_2', 'post_id_3']);

$response = $api->pinStreamSocialPost('STREAM_ID', 'POST_ID');

$feeds = $api->streamSocialFeeds('STREAM_ID');

$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
]);

$feed = $api->streamSocialFeed('STREAM_ID', 'FEED_ID');

$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
]);

$response = $api->deleteStreamSocialFeed('STREAM_ID', 'FEED_ID');

$response = $api->refreshStreamSocialFeed('STREAM_ID', 'FEED_ID');

$accounts = $api->streamSocialAccounts('STREAM_ID');

$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'
]);