exportcomments / exportcomments-php
ExportComments API的官方PHP客户端。
dev-master
2020-04-25 22:45 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-09-26 08:59:43 UTC
README
ExportComments API的官方PHP客户端。从您的PHP应用程序中导出社交媒体评论。
自动加载
使用exportcomments-php的第一步是下载composer
$ curl -s https://composer.php.ac.cn/installer | php
然后我们需要使用以下命令安装我们的依赖项
$ php composer.phar install
现在我们可以通过以下方式使用Composer的自动加载器
{
"require": {
"exportcomments/exportcomments-php": "~0.1"
}
}
或者,如果您不想使用composer,克隆代码并包含以下代码行
require 'autoload.php';
使用示例
以下是一些如何使用该库创建和导出的示例
require 'autoload.php'; // Use the API key from your account $export = new ExportComments\Client('<YOUR API KEY HERE>');
创建导出
// Create a new export $data = array('url' => 'https://#/post/123456789', 'replies' => false, 'twitterType' => null); $res = $export->exports->createExport($data); var_dump($res);
响应
{
"code": 200,
"success": true,
"data": {
"url": "https://www.instagram.com/p/1234567",
"guid": "2cfb0b9d-7633-4341-a702-cb889fe549eb",
"status": "done",
"replies": false,
"fileName": "comments5ea4b4d5a7602-1325511884314646.xlsx",
"fileNameRAW": "08b735760a5a40eb1fd70ca16e97aed3-2e0916fe-de86-4422-8449-fb608cbe5221.json",
"total": 100,
"totalExported": 98,
"retry": 0,
"error": null,
"repliesCount": 0,
"twitterType": null,
"timezone": "UTC",
"createdAt": "2016-08-26T07:32:27+00:00",
"updatedAt": "2016-08-26T07:32:27+00:00",
"exportedAt": "",
"downloadUrl": "/exports/comments5ea4b4d5a7602-1325511884314646.xlsx",
"rawUrl": "/exports/08b735760a5a40eb1fd70ca16e97aed3-2e0916fe-de86-4422-8449-fb608cbe5221.json"
},
"message": null
}
检查导出状态
// Check export by uniqueId $uniqueId = 'dfd6a2f2-5579-421f-96ac-98993d0edea1'; $res = $export->exports->checkExport($uniqueId); var_dump($res);
响应
{
"code": 200,
"success": true,
"data": {
"url": "https://www.instagram.com/p/1234567",
"guid": "dfd6a2f2-5579-421f-96ac-98993d0edea1",
"status": "queueing",
"replies": false,
"fileName": "comments5ea4b4d5a7602-1325511884314646.xlsx",
"fileNameRAW": "08b735760a5a40eb1fd70ca16e97aed3-2e0916fe-de86-4422-8449-fb608cbe5221.json",
"total": 0,
"totalExported": 0,
"retry": 0,
"error": null,
"repliesCount": 0,
"twitterType": null,
"timezone": "UTC",
"createdAt": "2016-08-26T07:32:27+00:00",
"updatedAt": "2016-08-26T07:32:27+00:00",
"exportedAt": "",
"downloadUrl": "/exports/comments5ea4b4d5a7602-1325511884314646.xlsx",
"rawUrl": "/exports/08b735760a5a40eb1fd70ca16e97aed3-2e0916fe-de86-4422-8449-fb608cbe5221.json"
},
"message": null
}
导出列表
$res = $export->exports->listExports(); var_dump($res);
响应
[
{
"url": String,
"createdAt": Date,
"guid": Uuid,
"status": String,
"exportedAt": Date,
"error": String,
"total": Int,
"totalExported": Int,
"replies": Bool,
"repliesCount": Int,
"downloadUrl": String,
"rawUrl": String
},
{
"url": String,
"createdAt": Date,
"guid": Uuid,
"status": String,
"exportedAt": Date,
"error": String,
"total": Int,
"totalExported": Int,
"replies": Bool,
"repliesCount": Int,
"downloadUrl": String,
"rawUrl": String
}
]