项目作者: aliyun

项目描述 :
Official repository of the Alibaba Cloud Client for PHP
高级语言: PHP
项目地址: git://github.com/aliyun/openapi-sdk-php-client.git
创建时间: 2018-11-29T03:54:18Z
项目社区:https://github.com/aliyun/openapi-sdk-php-client

开源协议:Other

下载


English | 简体中文

Alibaba Cloud Client for PHP

Latest Stable Version
composer.lock
Total Downloads
License
codecov
PHP Version Require

Alibaba Cloud Client for PHP is a client tool that helps PHP developers manage credentials and send requests, Alibaba Cloud SDK for PHP dependency on this tool.

Troubleshoot

Troubleshoot Provide OpenAPI diagnosis service to help developers locate quickly and provide solutions for developers through RequestID or error message.

Online Demo

Alibaba Cloud OpenAPI Developer Portal provides the ability to call the cloud product OpenAPI online, and dynamically generate SDK Example code and quick retrieval interface, which can significantly reduce the difficulty of using the cloud API.

Prerequisites

Your system will need to meet the Prerequisites, including having PHP >= 5.5. We highly recommend having it compiled with the cURL extension and cURL 7.16.2+.

Installation

If Composer is already installed globally on your system, run the following in the base directory of your project to install Alibaba Cloud Client for PHP as a dependency:

  1. composer require alibabacloud/client

Some users may not be able to install due to network problems, you can try to switch the Composer mirror.

Please see the Installation for more detailed information about installing the Alibaba Cloud Client for PHP through Composer and other means.

Quick Examples

Before you begin, you need to sign up for an Alibaba Cloud account and retrieve your Credentials.

Create Client

  1. <?php
  2. use AlibabaCloud\Client\AlibabaCloud;
  3. AlibabaCloud::accessKeyClient('accessKeyId', 'accessKeySecret')->asDefaultClient();

Request

Request styles are divided into ROA and RPC. Different product styles are different. Please refer to the product documentation before using. It is recommended to use Alibaba cloud SDK for PHP, the details have been encapsulated, and you do not need to care about the style.

ROA Request

  1. <?php
  2. use AlibabaCloud\Client\AlibabaCloud;
  3. use AlibabaCloud\Client\Exception\ClientException;
  4. use AlibabaCloud\Client\Exception\ServerException;
  5. try {
  6. $result = AlibabaCloud::roa()
  7. ->regionId('cn-hangzhou') // Specify the requested regionId, if not specified, use the client regionId, then default regionId
  8. ->product('CS') // Specify product
  9. ->version('2015-12-15') // Specify product version
  10. ->action('DescribeClusterServices') // Specify product interface
  11. ->serviceCode('cs') // Set ServiceCode for addressing, optional
  12. ->endpointType('openAPI') // Set type, optional
  13. ->method('GET') // Set request method
  14. ->host('cs.aliyun.com') // Location Service will not be enabled if the host is specified. For example, service with a Certification type-Bearer Token should be specified
  15. ->pathPattern('/clusters/[ClusterId]/services') // Specify path rule with ROA-style
  16. ->withClusterId('123456') // Assign values to parameters in the path. Method: with + Parameter
  17. ->request(); // Make a request and return to result object. The request is to be placed at the end of the setting
  18. print_r($result->toArray());
  19. } catch (ClientException $exception) {
  20. print_r($exception->getErrorMessage());
  21. } catch (ServerException $exception) {
  22. print_r($exception->getErrorMessage());
  23. }

RPC Request

  1. <?php
  2. use AlibabaCloud\Client\AlibabaCloud;
  3. use AlibabaCloud\Client\Exception\ClientException;
  4. use AlibabaCloud\Client\Exception\ServerException;
  5. try {
  6. $result = AlibabaCloud::rpc()
  7. ->product('Cdn')
  8. ->version('2014-11-11')
  9. ->action('DescribeCdnService')
  10. ->method('POST')
  11. ->request();
  12. print_r($result->toArray());
  13. } catch (ClientException $exception) {
  14. print_r($exception->getErrorMessage());
  15. } catch (ServerException $exception) {
  16. print_r($exception->getErrorMessage());
  17. }

Documentation

Issues

Opening an Issue, Issues not conforming to the guidelines may be closed immediately.

Changelog

Detailed changes for each release are documented in the release notes.

Contribution

Please make sure to read the Contributing Guide before making a pull request.

References

License

Apache-2.0

Copyright (c) 2009-present, Alibaba Cloud All rights reserved.