Skip to content

Commit 76a18b5

Browse files
author
root
committed
moved to API v2
1 parent 2ba76c2 commit 76a18b5

File tree

3 files changed

+82
-53
lines changed

3 files changed

+82
-53
lines changed

README.md

+69-44
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# exportcomments-php
2+
23
Official PHP client for the ExportComments API. Export Social Media Comments from your PHP apps.
34

4-
Autoload
5-
--------
5+
## Autoload
66

77
The first step to use `exportcomments-php` is to download composer:
88

@@ -11,28 +11,29 @@ $ curl -s http://getcomposer.org/installer | php
1111
```
1212

1313
Then we have to install our dependencies using:
14+
1415
```bash
1516
$ php composer.phar install
1617
```
18+
1719
Now we can use autoloader from Composer by:
1820

1921
```json
2022
{
21-
"require": {
22-
"exportcomments/exportcomments-php": "~0.1"
23-
}
23+
"require": {
24+
"exportcomments/exportcomments-php": "~0.1"
25+
}
2426
}
2527
```
2628

2729
Or, if you don't want to use composer, clone the code and include this line of code:
2830

2931
require 'autoload.php';
3032

31-
32-
Usage examples
33-
--------------
33+
## Usage examples
3434

3535
Here are some examples of how to use the library in order to create and use exports:
36+
3637
```php
3738
require 'autoload.php';
3839

@@ -42,6 +43,7 @@ $export = new ExportComments\Client('<YOUR API KEY HERE>');
4243
```
4344

4445
Create export
46+
4547
```php
4648
// Create a new export
4749
$data = array('url' => 'https://www.facebook.com/post/123456789', 'replies' => false, 'twitterType' => null);
@@ -53,16 +55,35 @@ var_dump($res);
5355
Response
5456

5557
```json
56-
5758
{
58-
"uniqueId": "dfd6a2f2-5579-421f-96ac-98993d0edea1",
59-
"date_created": "2016-08-26T11:44:09+00:00",
60-
"status": false,
61-
"error": null
59+
"code": 200,
60+
"success": true,
61+
"data": {
62+
"url": "https://www.instagram.com/p/1234567",
63+
"guid": "2cfb0b9d-7633-4341-a702-cb889fe549eb",
64+
"status": "done",
65+
"replies": false,
66+
"fileName": "comments5ea4b4d5a7602-1325511884314646.xlsx",
67+
"fileNameRAW": "08b735760a5a40eb1fd70ca16e97aed3-2e0916fe-de86-4422-8449-fb608cbe5221.json",
68+
"total": 100,
69+
"totalExported": 98,
70+
"retry": 0,
71+
"error": null,
72+
"repliesCount": 0,
73+
"twitterType": null,
74+
"timezone": "UTC",
75+
"createdAt": "2016-08-26T07:32:27+00:00",
76+
"updatedAt": "2016-08-26T07:32:27+00:00",
77+
"exportedAt": "",
78+
"downloadUrl": "/exports/comments5ea4b4d5a7602-1325511884314646.xlsx",
79+
"rawUrl": "/exports/08b735760a5a40eb1fd70ca16e97aed3-2e0916fe-de86-4422-8449-fb608cbe5221.json"
80+
},
81+
"message": null
6282
}
63-
6483
```
6584

85+
````
86+
6687
Checking export status
6788
6889
```php
@@ -71,32 +92,40 @@ $uniqueId = 'dfd6a2f2-5579-421f-96ac-98993d0edea1';
7192
$res = $export->exports->checkExport($uniqueId);
7293
var_dump($res);
7394
74-
```
95+
````
7596

7697
Response
77-
```json
7898

79-
[
80-
{
99+
```json
100+
{
101+
"code": 200,
102+
"success": true,
103+
"data": {
81104
"url": "https://www.instagram.com/p/1234567",
82-
"datecreated": "2016-08-26T07:32:09+00:00",
83-
"uniqueId": "dfd6a2f2-5579-421f-96ac-98993d0edea1",
84-
"done": true,
85-
"dateexported": "2016-08-26T07:32:27+00:00",
105+
"guid": "2cfb0b9d-7633-4341-a702-cb889fe549eb",
106+
"status": "queueing",
107+
"replies": false,
108+
"fileName": "comments5ea4b4d5a7602-1325511884314646.xlsx",
109+
"fileNameRAW": "08b735760a5a40eb1fd70ca16e97aed3-2e0916fe-de86-4422-8449-fb608cbe5221.json",
110+
"total": 0,
111+
"totalExported": 0,
112+
"retry": 0,
86113
"error": null,
87-
"total": 306,
88-
"totalExported": 306,
89-
"replies": true,
90-
"dateNotified": null,
91114
"repliesCount": 0,
92-
"downloadUrl": "/exports/comments5d638af93ab70-1234567.xlsx",
93-
"rawUrl": "/exports/6dbf1a87e0fb1f7f16b25be55bb37647-148d4d42-9db8-4e5a-9b51-a860e3646cb0.json"
94-
}
95-
]
96-
115+
"twitterType": null,
116+
"timezone": "UTC",
117+
"createdAt": "2016-08-26T07:32:27+00:00",
118+
"updatedAt": "2016-08-26T07:32:27+00:00",
119+
"exportedAt": "",
120+
"downloadUrl": "/exports/comments5ea4b4d5a7602-1325511884314646.xlsx",
121+
"rawUrl": "/exports/08b735760a5a40eb1fd70ca16e97aed3-2e0916fe-de86-4422-8449-fb608cbe5221.json"
122+
},
123+
"message": null
124+
}
97125
```
98126

99127
Exports list
128+
100129
```php
101130

102131
$res = $export->exports->listExports();
@@ -107,38 +136,34 @@ var_dump($res);
107136
Response
108137

109138
```json
110-
111139
[
112140
{
113141
"url": String,
114-
"datecreated": Date,
115-
"uniqueId": Uuid,
116-
"done": Bool,
117-
"dateexported": Date,
142+
"createdAt": Date,
143+
"guid": Uuid,
144+
"status": String,
145+
"exportedAt": Date,
118146
"error": String,
119147
"total": Int,
120148
"totalExported": Int,
121149
"replies": Bool,
122-
"dateNotified": Date,
123150
"repliesCount": Int,
124151
"downloadUrl": String,
125152
"rawUrl": String
126153
},
127154
{
128155
"url": String,
129-
"datecreated": Date,
130-
"uniqueId": Uuid,
131-
"done": Bool,
132-
"dateexported": Date,
156+
"createdAt": Date,
157+
"guid": Uuid,
158+
"status": String,
159+
"exportedAt": Date,
133160
"error": String,
134161
"total": Int,
135162
"totalExported": Int,
136163
"replies": Bool,
137-
"dateNotified": Date,
138164
"repliesCount": Int,
139165
"downloadUrl": String,
140166
"rawUrl": String
141167
}
142168
]
143-
144-
```
169+
```

src/Config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
class Config {
66

7-
const DEFAULT_BASE_ENDPOINT = 'https://exportcomments.com/api';
7+
const DEFAULT_BASE_ENDPOINT = 'https://exportcomments.com/api/v2';
88

99
}

src/Exports.php

+12-8
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
use ExportComments\ExportCommentsResponse;
66
use ExportComments\ExportCommentsException;
77

8-
class Exports extends Request {
8+
class Exports extends Request
9+
{
910

10-
function __construct($token, $base_endpoint) {
11+
function __construct($token, $base_endpoint)
12+
{
1113
$this->token = $token;
1214
$this->endpoint = $base_endpoint;
1315
}
1416

15-
function checkExport($uniqueId) {
17+
function checkExport($guid)
18+
{
1619
$url = $this->endpoint . '/export';
1720
$query_params = http_build_query(
18-
array('uniqueId' => $uniqueId)
21+
array('guid' => $guid)
1922
);
2023
$url = $url . '?' . $query_params;
2124
try {
@@ -26,7 +29,8 @@ function checkExport($uniqueId) {
2629
return new ExportCommentsResponse($response, array($header));
2730
}
2831

29-
function createExport($data = array()) {
32+
function createExport($data = array())
33+
{
3034
$url = $this->endpoint . '/export';
3135
$params = array(
3236
'url' => $data['url'],
@@ -37,14 +41,15 @@ function createExport($data = array()) {
3741
}
3842
$url = $url . '?' . http_build_query($params);
3943
try {
40-
list($response, $header) = $this->make_request($url, 'POST');
44+
list($response, $header) = $this->make_request($url, 'PUT');
4145
} catch (ExportCommentsException $ex) {
4246
throw $ex;
4347
}
4448
return new ExportCommentsResponse($response, array($header));
4549
}
4650

47-
function listExports() {
51+
function listExports()
52+
{
4853
$url = $this->endpoint . '/exports/me';
4954
try {
5055
list($response, $header) = $this->make_request($url, 'GET', null);
@@ -53,5 +58,4 @@ function listExports() {
5358
}
5459
return new ExportCommentsResponse($response, array($header));
5560
}
56-
5761
}

0 commit comments

Comments
 (0)