定制 jpcaparas/trademe-php-api 二次开发

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

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

jpcaparas/trademe-php-api

最新稳定版本:v0.2

Composer 安装命令:

composer require jpcaparas/trademe-php-api

包简介

A PHP client for the Trade Me API

README 文档

README

Build Status Coverage Status

An unofficial PHP client to make it easy to interface with Trade Me's API platform.

Installation

composer require jpcaparas/trademe-php-api

Authorizing

Getting temporary access tokens (Step 1)

$config = [
    'sandbox' => true,
    'oauth' => [
        'consumer_key' => 'foo',
        'consumer_secret' => 'bar',
    ],
];
    
$client = new \JPCaparas\TradeMeAPI\Client($config);

['oauth_token' => $tempAccessToken, 'oauth_token_secret' => $tempAccessTokenSecret] = $client->getTemporaryAccessTokens();

Getting the OAuth token verifier to validate temporary access tokens (Step 2)

$tokenVerifierUrl = $client->getAccessTokenVerifierURL($tempOAuthToken); // Visit this URL and store the verifier code

Getting the final access tokens (Step 3)

// The config values are a culmination of steps 1 and 2
$config = [
    'temp_token' => 'baz',
    'temp_token_secret' => 'qux',
    'token_verifier' => 'quux'
];

['oauth_token' => $accessToken, 'oauth_token_secret' => $accessTokenSecret] = $client->getFinalAccessTokens($config);

Making API calls

You can make API calls once you've gotten your final access tokens:

Selling an item

$config = [
    'sandbox' => true,
    'oauth' => [
        'consumer_key' => 'foo',
        'consumer_secret' => 'bar',
        'token' => 'baz',
        'token_secret' => 'qux',
        'token_verifier' => 'quu',
    ],
];

$client = new Client($config);

$params = [
    'Category' => 'TestCategory',
    'Title' => 'TestTitle',
    'Description' => ['TestDescriptionLine1'],
    'Duration' => 1,
    'BuyNowPrice' => 99,
    'StartPrice' => 90,
    'PaymentMethods' => [2, 4],
    'Pickup' => 1,
    'ShippingOptions' => [
        ['Type' => 1],
    ],
];

$client->sellItem($params);

Tests

vendor/bin/phpunit

References

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-12