sleiman/addcontext-php

PHP包装器,用于连接AddContext.io API并基于事件/动作保存上下文快照

1.1.2 2018-04-14 11:37 UTC

This package is auto-updated.

Last update: 2024-08-29 05:05:47 UTC


README

一个用于AddContext API的PHP包装器。欢迎提供反馈或错误报告。

开始使用

安装

如果你使用Composer,可以运行以下命令

composer require sleiman/addcontext-php

你也可以直接下载并解压到你的Web目录。

将包装器添加到你的项目中

如果你使用Composer,运行自动加载器

require 'vendor/autoload.php';

或者包含Addcontext.php文件

include('../src/Addcontext.php');

初始化类

use \TANIOS\Addcontext\Addcontext;
$addcontext = new Addcontext(array(
    'access_token' => 'ACCESS_TOKEN',
));

创建新的快照请求

我们想要通过API在系统中创建一个新的条目

// 将任何你想要关联到该快照的元数据添加到数组中

$metadata['text_main_entity']   = 'russia';
$metadata['sent_from']   = 'iphone';
$metadata['tweet_id'] = '123213213';
$metadata['tweet_content']    = 'messsage text';

// Add all the information you have to an array (email, datetime and rule are mandatory)
// Add the metada array to the fields array

$fields = array(
    'email' => "someletters@youcanread.com",
    'datetime'=> "2018-03-01 19:08:00",
    'rule' => 'trump tweeted',
    'metadata'=> $metadata
);

// Create the snapshot 
$new_snapshot = $addcontext->createSnapshotRequest($fields);

鸣谢

版权所有 (c) 2018 - 由Sleiman Tanios编写