v3toys/yii2-v3project-api

此包已被废弃且不再维护。作者建议使用v3toys/yii2-v3project-api包。

V3toys yii2 api

安装: 179

依赖: 0

建议: 0

安全: 0

星星: 0

关注者: 2

分支: 0

类型:yii2-extension

2.0.1 2019-03-14 11:20 UTC

This package is auto-updated.

Last update: 2022-02-01 13:01:42 UTC


README

信息

安装

通过以下方式安装此扩展程序是首选:composer

在composer.json中添加

"repositories": [
    {
        "type": "git",
        "url":  "https://github.com/v3toys/yii2-v3project-api.git"
    }
],

运行以下命令之一

php composer.phar require --prefer-dist v3toys/yii2-v3project-api "*"

或添加以下内容

"v3toys/yii2-v3project-api": "*"

如何使用

//App config
[
    'components'    =>
    [
    //....
        'v3projectApi' =>
        [
            'class'             => 'v3toys\v3project\api\Api',
            'affiliate_key'     => 'fff',
            'timeout'           => 12,
        ],
    //....
    ]
]

示例

$response = \Yii::$app->v3projectApi->send('/product/find', [
    'filters' =>
    [
        'v3p_product_ids' => [186893]
    ]
]);

or

$response = \Yii::$app->v3projectApi->productFind([
    'filters' =>
    [
        'v3p_product_ids' => [186893]
    ],
    'params' =>
    [
        'format' => 'full'
    ]
]);

print_r($response->httpClientRequest->url);     //Full api url
print_r($response->httpClientRequest->data);    //Request data
print_r($response->httpClientRequest->method);  //Request method
print_r($response->httpClientRequest->headers); //Request headers

print_r($response->httpClientResponse->statusCode); //Server response code
print_r($response->httpClientResponse->content);    //Original api response

if ($response->isError)
{
    print_r($response->errorMessage); //Расшифровка кода
    print_r($response->errorData);
    print_r($response->errorCode);
} else
{
    print_r($response->data); //Array response data
}

skeeks!
SkeekS CMS (Yii2) — 快速、简单、有效!
skeeks.com | cms.skeeks.com | marketplace.cms.skeeks.com