mirror of
https://github.com/avecms/AVE.cms.git
synced 2026-08-01 08:45:44 +00:00
1.2 KiB
1.2 KiB
MarketParser - external API client
App\Helpers\MarketParser - wrapper over external API MarketParser (prices and reports,
Yandex.Market-like service). Used as an instance with an API key and ID
campaigns.
use App\Helpers\MarketParser;
$client = new MarketParser($apiKey, $campaignId);
Methods
| Method | Destination |
|---|---|
__construct($apiKey, $campaignId) |
Create a client. |
getCampaigns() |
List of campaigns. |
getPriceInfo() |
Price information. |
createReport() |
Create report (returns job ID). |
getReportInfo($reportId) |
Report status/metadata. |
getReportResults($reportId, $perPage = 10) |
Report results (page by page). |
getReportsList() |
List of previously created reports. |
Recipe
Create a report and wait for the results:
$client = new MarketParser($apiKey, $campaignId);
$report = $client->createReport();
$info = $client->getReportInfo($report['id']); // проверить готовность
$rows = $client->getReportResults($report['id'], 50);
Take the API key and campaign ID from the settings, do not hardcode it. These are network calls - wrap in
try/catchand take into account API timeouts/limits.