postedin/docode-php

消耗 https://docode.cl API 的库

1.0.0-beta2 2018-02-12 16:34 UTC

This package is not auto-updated.

Last update: 2024-09-13 23:26:21 UTC


README

消耗 https://docode.cl API 的 PHP 库

Packagist Packagist CircleCI

安装

https://packagist.org.cn/packages/postedin/docode-php

composer require postedin/docode-php

设置

您需要手动获取令牌。由于需要明文用户名和密码,因此我们不支持在此软件包中获取令牌。
要获取您的令牌,请使用该信息手动请求 Docode API。

您可以在终端中使用 curl 来完成此操作

curl -X POST -H "Content-Type:application/json" https://docode.cl/app/api/token -d '{"username": "YOUR USERNAME HERE", "password": "YOUR_PASSWORD_HERE"}'

或者,我们使用 https://insomnia.rest/ 来测试 API 并进行手动请求。

基本用法

来自示例目录

<?php

use Postedin\Docode;

require __DIR__ . '/../vendor/autoload.php';

$api = new Docode\DocodeApi('token here');

$content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas accumsan, purus at dignissim convallis, nisi lacus pellentesque ligula, lobortis ornare lorem est eget nulla. Vestibulum ultrices, erat non consequat tincidunt, dolor justo consectetur nibh, non vehicula risus sem sit amet enim.';

// returns an instance of Docode\Analysis
$analysis = $api->createAnalysis('test-example.txt', $content, 'http://postedin.test/callback-url/')->analyseWeb();

// At this point docode will be analysing your content and when done send results to your callback URL. 
// You also have the data from the request as objects from this library. 

// You can get the results manually by doing...
$newResponseAnalysis = $api->getAnalysis($analysis->id);

// if docode is done this will contain the results, if any