thoughtchimp/unengage-api-wrapper

此包已被弃用且不再维护。未建议替换包。

Unengage API 包装器

v1.0.5 2017-12-15 08:30 UTC

This package is not auto-updated.

Last update: 2020-06-26 20:18:51 UTC


README

此存储库包含开源 PHP SDK,允许您从您的 PHP 应用程序访问 Unengage API。

安装

可以使用 Composer 安装 Unengage SDK。运行此命令

composer require thoughtchimp/unengage-api-wrapper

用法

注意:此版本的 PHP Unengage SDK 需要 PHP 5.5 或更高版本。

实例化 SDK

use Unengage\API;

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

获取所有流

$streams = $api->streams();

通过 ID 获取流

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

创建流

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

通过 ID 更新特定流

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

通过 ID 删除流

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

通过传递流 ID 获取流社交帖子

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

通过传递流 ID、平台和 post_url 获取流社交帖子预览

$post = $api->streamSocialPostPreview('STREAM_ID', 'platform goest here ex: twitter', 'post_url goes here ex: twitter post url');

通过传递流 ID、平台和 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'
]);

通过传递帖子 ID 更新流中的社交帖子

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

通过 ID 删除流

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

通过 ID 获取特定社交源

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

完整的文档可在此处找到。