dilneiss/mercadolibre-php-sdk
Composer 安装命令:
composer require dilneiss/mercadolibre-php-sdk
包简介
This is a the codebase to generate a SDK for Open Platform Marketplace
关键字:
README 文档
README
MercadoLibre's PHP SDK
This is the official PHP SDK for MercadoLibre's Platform.
Requirements
PHP 8.0 and later
Installation & Usage
Composer
To install the bindings via Composer, add the following to composer.json:
{
"require": {
"climba-commerce/mercadolibre-php-sdk": "^v3.1"
}
}
Then run composer install
Manual Installation
Download the files
Run composer install
Include autoload.php in your code:
require_once('/path-to-integration-folder/vendor/autoload.php');
Tests
To run the unit tests:
composer install ./vendor/bin/phpunit
Usage
<?php require_once(__DIR__ . '/vendor/autoload.php'); $config = new Meli\Configuration(); $servers = $config->getHostSettings(); // Auth URLs Options by country // 1: "https://auth.mercadolibre.com.ar" // 2: "https://auth.mercadolivre.com.br" // 3: "https://auth.mercadolibre.com.co" // 4: "https://auth.mercadolibre.com.mx" // 5: "https://auth.mercadolibre.com.uy" // 6: "https://auth.mercadolibre.cl" // 7: "https://auth.mercadolibre.com.cr" // 8: "https://auth.mercadolibre.com.ec" // 9: "https://auth.mercadolibre.com.ve" // 10: "https://auth.mercadolibre.com.pa" // 11: "https://auth.mercadolibre.com.pe" // 12: "https://auth.mercadolibre.com.do" // 13: "https://auth.mercadolibre.com.bo" // 14: "https://auth.mercadolibre.com.py" // Use the correct auth URL $config->setHost($servers[1]["url"]); // Or Print all URLs print_r($servers); // Or Print or Put the following URL in your browser window to obtain authorization: // // http://auth.mercadolibre.com.ar/authorization?response_type=code&client_id=$APP_ID&redirect_uri=$YOUR_URL ?>
This will give you the url to redirect the user. You need to specify a callback url which will be the one that the user will redirected after a successfull authrization process.
Once the user is redirected to your callback url, you'll receive in the query string, a parameter named code. You'll need this for the second part of the process
Examples for OAuth - get token
<?php require_once(__DIR__ . '/vendor/autoload.php'); $apiInstance = new Meli\Api\OAuth20Api( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client() ); $grant_type = 'authorization_code'; $client_id = 'client_id_example'; // Your client_id $client_secret = 'client_secret_example'; // Your client_secret $redirect_uri = 'redirect_uri_example'; // Your redirect_uri $code = 'code_example'; // The parameter CODE $refresh_token = 'refresh_token_example'; // Your refresh_token try { $result = $apiInstance->getToken($grant_type, $client_id, $client_secret, $redirect_uri, $code, $refresh_token); print_r($result); } catch (Exception $e) { echo 'Exception when calling OAuth20Api->getToken: ', $e->getMessage(), PHP_EOL; } ?>
Example using the RestClient with a POST Item
<?php require_once(__DIR__ . '/vendor/autoload.php'); $apiInstance = new Meli\Api\RestClientApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client() ); $resource = 'resource_example'; // string | for example: items $access_token = 'access_token_example'; // string | $options = ['headers' => ['access_token' => $access_token]]; // array | $body = new \stdClass; // object | try { $apiInstance->resourcePost($resource, $options, $body); } catch (Exception $e) { echo 'Exception when calling RestClientApi->resourcePost: ', $e->getMessage(), PHP_EOL; } ?>
Documentation & Important notes
The URIs are relative to https://api.mercadolibre.com
The Authorization URLs (set the correct country domain): https://auth.mercadolibre.{country_domain}
All docs for the library are located here
Check out our examples codes in the folder examples
Don’t forget to check out our developer site
dilneiss/mercadolibre-php-sdk 适用场景与选型建议
dilneiss/mercadolibre-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 412 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 08 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「rest」 「api」 「sdk」 「MercadoLibre」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dilneiss/mercadolibre-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dilneiss/mercadolibre-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dilneiss/mercadolibre-php-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
Alfabank REST API integration
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
BlockCypher's PHP SDK for REST API
Helper classes for creating cookie headers
统计信息
- 总下载量: 412
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: unlicense
- 更新时间: 2021-08-17