Official PHP client for the ExportComments API v3. Export comments and reviews from 40+ social media and review platforms.
- PHP 7.4 or higher
- JSON extension
- cURL extension
composer require exportcomments/exportcomments-phpgit clone https://github.com/exportcomments/exportcomments-php.gitThen include the autoloader in your project:
require_once 'path/to/exportcomments-php/autoload.php';<?php
require_once 'vendor/autoload.php';
$export = new ExportComments\Client('<YOUR API KEY HERE>');$res = $export->ping();
var_dump($res->result); // ['message' => 'pong']$data = array(
'url' => 'https://www.instagram.com/p/ABC123/',
'replies' => false,
'limit' => 100
);
$res = $export->exports->createExport($data);
$guid = $res->result['guid'];$res = $export->exports->checkExport($guid);
$status = $res->result['status']; // 'queueing', 'progress', 'done', 'error'// Download the Excel/CSV file for a completed job
$filePath = $export->exports->downloadExport($guid);
echo "Saved to: $filePath";
// Or specify a custom output path
$filePath = $export->exports->downloadExport($guid, '/path/to/output.xlsx');$data = $export->exports->downloadJson($guid);
foreach ($data as $comment) {
echo $comment['message'] . ' - ' . $comment['author_name'] . "\n";
}$res = $export->exports->listExports($page = 1, $limit = 10);
var_dump($res->result);$data = array(
'url' => 'https://twitter.com/user/status/123456789',
'options' => array(
'replies' => true,
'limit' => 500,
'vpn' => 'Norway',
'cookies' => array(
'auth_token' => 'your_twitter_auth_token'
),
'minTimestamp' => 1622505600,
'maxTimestamp' => 1625097600
)
);
$res = $export->exports->createExport($data);try {
$res = $export->exports->createExport($data);
} catch (ExportComments\ExportCommentsException $e) {
echo "Error: " . $e->getMessage();
}<?php
require_once 'vendor/autoload.php';
$export = new ExportComments\Client('<YOUR API KEY HERE>');
// Verify connectivity
$export->ping();
// Create export
try {
$res = $export->exports->createExport([
'url' => 'https://www.instagram.com/p/ABC123/',
'options' => ['replies' => true, 'limit' => 100]
]);
} catch (ExportComments\ExportCommentsException $e) {
die("Error: " . $e->getMessage());
}
$guid = $res->result['guid'];
// Poll until done
while (true) {
$res = $export->exports->checkExport($guid);
$status = $res->result['status'];
if ($status === 'done') break;
if ($status === 'error') die("Error: " . $res->result['error']);
sleep(5);
}
// Download the file
$filePath = $export->exports->downloadExport($guid);
echo "Downloaded: $filePath\n";
// Or get raw JSON data
$data = $export->exports->downloadJson($guid);
echo "Got " . count($data) . " comments\n";composer testcomposer cs-check
composer cs-fixMIT - see LICENSE.txt for details.