定制 matasarei/olx-api-client-v2 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

matasarei/olx-api-client-v2

最新稳定版本:1.1.2

Composer 安装命令:

composer require matasarei/olx-api-client-v2

包简介

OLX API Client v2

README 文档

README

CI workflow

This package implements PHP client for OLX Partner API.

Installation

To install the package to your project via Composer simply run:

composer require matasarei/olx-api-client-v2

Documentation

Official OLX API documentation and developers portal:

Check the troubleshooting section if you have any issues.

Usage

Basic Example

use Gentor\Olx\Api\Client;
use Gentor\Olx\Api\Credentials;

$credentials = new Credentials('your_client_id', 'your_client_secret');
$client = new Client($credentials, Client::OLX_UA);

// Create an advert
$response = $client->adverts()->create([
    'title' => 'My Product',
    'description' => 'Product description...',
    'category_id' => 123,
    // ... other required fields
]);

// Access the created advert data
$advertData = $response['data'];
echo "Created advert ID: " . $advertData['id'];
echo "Status: " . $advertData['status'];

Important: API Response Format

All OLX API responses wrap the actual data in a data key according to the official API specification:

// What you get from the API:
[
  'data' => [
    'id' => 905890605,
    'status' => 'active',
    // ... other advert fields
  ]
]

// Access the actual data:
$response = $client->adverts()->create($request);
$advertData = $response['data'];

This response format applies to advert-related endpoints, for example:

  • GET /adverts returns ['data' => [array of adverts]]
  • POST /adverts returns ['data' => {advert object}]
  • GET /adverts/{id} returns ['data' => {advert object}]
  • PUT /adverts/{id} returns ['data' => {advert object}]

Other endpoints may have different response structures. Please refer to the official OLX API documentation for details on the response format of each endpoint.

Testing and development

  1. Install vendors
docker run --rm -v $(pwd):/app -w /app composer:lts composer install
  1. Run tests
docker run --rm -v $(pwd):/app -w /app composer:lts vendor/bin/phpunit

统计信息

  • 总下载量: 20.73k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-19