项目作者: aliyun

项目描述 :
Alibaba Cloud SDK for PHP
高级语言: PHP
项目地址: git://github.com/aliyun/openapi-sdk-php.git
创建时间: 2019-01-02T01:54:43Z
项目社区:https://github.com/aliyun/openapi-sdk-php

开源协议:Other

下载


English | 简体中文

Alibaba Cloud SDK for PHP

Latest Stable Version
composer.lock
Total Downloads
License
codecov
Travis Build Status
Appveyor Build Status

AlibabaCloud

The Alibaba Cloud V1.0 SDK will soon enter the Basic Security Maintenance phase and is no longer recommended for use. It is suggested to use the V2.0 SDK instead.

Release Notes

We developed a new kernel on the principle of eliminating known issues and compatible with old grammar, adding the following features:

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 SDK for PHP as a dependency:

  1. composer require alibabacloud/sdk

Please see the Installation for more detailed information about installing through Composer and other ways.

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.

Quick Examples

Before you begin, you need to sign up for an Alibaba Cloud account and retrieve your Credentials. Before request, please Understanding the Clients, after request, please Understanding the Result.

Currently, only some Alibaba Cloud products are supported, Supported Products, For products that are not supported, you can use Alibaba Cloud Client for PHP to initiate custom requests, and you can use Alibaba Cloud OpenAPI Developer Portal to generate Alibaba Cloud Client for PHP code online.

  1. <?php
  2. use AlibabaCloud\Client\AlibabaCloud;
  3. use AlibabaCloud\Client\Exception\ClientException;
  4. use AlibabaCloud\Client\Exception\ServerException;
  5. use AlibabaCloud\Ecs\Ecs;
  6. // Set up a global client
  7. AlibabaCloud::accessKeyClient('foo', 'bar')
  8. ->regionId('cn-hangzhou')
  9. ->asDefaultClient();
  10. try {
  11. // Access product APIs
  12. $request = Ecs::v20140526()->describeRegions();
  13. // Set options/parameters and execute request
  14. $result = $request->withResourceType('type') // API parameter
  15. ->withInstanceChargeType('type') // API parameter
  16. ->client('client1') // Specify the client for send
  17. ->debug(true) // Enable the debug will output detailed information
  18. ->connectTimeout(0.01) // Throw an exception when Connection timeout
  19. ->timeout(0.01) // Throw an exception when timeout
  20. ->request(); // Execution request
  21. // Can also Set by passing in an array
  22. $options = [
  23. 'debug' => true,
  24. 'connect_timeout' => 0.01,
  25. 'timeout' => 0.01,
  26. 'query' => [
  27. 'ResourceType' => 'type',
  28. 'InstanceChargeType' => 'type',
  29. ],
  30. ];
  31. // Settings priority
  32. $result2 = Ecs::v20140526()
  33. ->describeRegions($options)
  34. ->options([
  35. 'query' => [
  36. 'Key' => 'I will overwrite this value in constructor',
  37. 'new' => 'I am new value',
  38. ],
  39. ])
  40. ->options([
  41. 'query' => [
  42. 'Key' => 'I will overwrite the previous value',
  43. 'bar' => 'I am new value',
  44. ],
  45. ])
  46. ->debug(false) // Overwrite the true of the former
  47. ->request();
  48. } catch (ClientException $exception) {
  49. echo $exception->getMessage(). PHP_EOL;
  50. } catch (ServerException $exception) {
  51. echo $exception->getMessage() . PHP_EOL;
  52. echo $exception->getErrorCode(). PHP_EOL;
  53. echo $exception->getRequestId(). PHP_EOL;
  54. echo $exception->getErrorMessage(). PHP_EOL;
  55. }

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.