Alibaba Cloud SDK for PHP

Overview

English | 简体中文

Alibaba Cloud SDK for PHP

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

AlibabaCloud

Alibaba Cloud SDK for PHP is a development kit that supports quick access to products, dependency on Alibaba Cloud Client for PHP.

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:

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.

<?php

use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
use AlibabaCloud\Ecs\Ecs;

// Set up a global client
AlibabaCloud::accessKeyClient('foo', 'bar')
            ->regionId('cn-hangzhou')
            ->asDefaultClient();

try {
    // Access product APIs
    $request = Ecs::v20140526()->describeRegions();
    
    // Set options/parameters and execute request
    $result = $request->withResourceType('type') // API parameter
                      ->withInstanceChargeType('type') // API parameter
                      ->client('client1') // Specify the client for send
                      ->debug(true) // Enable the debug will output detailed information
                      ->connectTimeout(0.01) // Throw an exception when Connection timeout 
                      ->timeout(0.01) // Throw an exception when timeout 
                      ->request(); // Execution request

    // Can also Set by passing in an array
    $options = [
                   'debug'           => true,
                   'connect_timeout' => 0.01,
                   'timeout'         => 0.01,
                   'query'           => [
                       'ResourceType' => 'type',
                       'InstanceChargeType' => 'type',
                   ],
               ];
    
    // Settings priority
    $result2 = Ecs::v20140526()
                  ->describeRegions($options)
                  ->options([
                                'query' => [
                                    'Key'      => 'I will overwrite this value in constructor',
                                    'new'      => 'I am new value',
                                ],
                            ])
                  ->options([
                                'query' => [
                                    'Key' => 'I will overwrite the previous value',
                                    'bar' => 'I am new value',
                                ],
                            ])
                  ->debug(false) // Overwrite the true of the former
                  ->request();
    
} catch (ClientException $exception) {
    echo $exception->getMessage(). PHP_EOL;
} catch (ServerException $exception) {
    echo $exception->getMessage() . PHP_EOL;
    echo $exception->getErrorCode(). PHP_EOL;
    echo $exception->getRequestId(). PHP_EOL;
    echo $exception->getErrorMessage(). PHP_EOL;
}

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.

Comments
  • 容器镜像服务Cr  配置问题

    容器镜像服务Cr 配置问题

    • PHP 版本:7.2.6
    • 平台:docker alpine
    • 产品名称:容器镜像服务Cr
    • 产品版本:20160607
    • API:getRepoList

    代码基本是拿官网文档过来后做的修改:

    AlibabaCloud::accessKeyClient('xxx','xxx')->regionId('cn-hangzhou')->asDefaultClient();
    
    try {
    	$options = [
    	    'debug' => true,
    	    'query' => [
    	        'Status' => 'NORMAL',
    	        'RepoNamePrefix' => ''
    	    ]
    	];
    	$request = Cr::v20160607()
    	            ->getRepoList($options);
    
    	$r = $request->request();
    } catch (ServerException $e) {
        echo $e->getResult();
    }
    

    最后捕获打出来的结果是:

    {"RequestId":"806D70E8-32B0-4F18-8C8A-CA54E5D22E2E","HostId":"location.aliyuncs.com","Code":"Illegal Parameter","Message":"Please check the parameters"}
    

    不清楚是哪里参数有误。 而且API文档https://help.aliyun.com/document_detail/72399.html 上还有个RepoNamePrefix参数,要求是必须提供该参数,但SDK中又没有AlibabaCloud\Cr\V20160607\GetRepoList::withRepoNamePrefix()这样的函数,所以我通过options['query']进行了传递,不知道是否正确。

    accessKeyId和accessKeySecret都是正确的 到底哪里出现了参数错误?

    为了偷懒,我copy了别人提交的一样反馈记录.

    opened by yizhihouzi 17
  • Image search empty codes

    Image search empty codes

    I am currently testing Image search from this repo, but unfortunately, I am sending an empty request as per stated by the Support Engineer when doing tickets in the console. I am writing here as it was suggested by the Support engineer to raise an issue here instead.

    My question is that, why is the Image search codes are empty compare to the Aliyun open api sdk or the downloadable library

    Any way you can update the image search? As I really prefer to use composer when installing libraries.

    If you have a question about Alibaba Cloud that is not a bug report or feature request, please post it in https://selfservice.console.aliyun.com/ticket/createIndex

    Questions posted to this repository will be closed.

    opened by rfpdl 16
  • mnsClient BatchReceiveMessage 参数bug

    mnsClient BatchReceiveMessage 参数bug

    • PHP Version:7.2
    • Platform:mac
    • Product:mns
    • Product Version:1.2.4
    • API: BatchReceiveMessage

    hi
    sdk中提供的mnsClient存在参数问题 导致无法正常获取mns队列消息

    我方在升级使用新版php-sdk, 出现无法拉取mns消息bug 阿里云官方工单反馈如下 工程师 60810 号 : 您好,已经为您核实,您的这个sdk不是消息服务mns官方提供的sdk,传的参数WaitSeconds 这个是非标准的,标准的应该是:waitseconds,还要请您知晓哈,官方提供的mns的sdk,您可以参考下 https://help.aliyun.com/document_detail/32381.html?spm=a2c4g.11186623.6.655.2b947f87MOpJpF 您使用这个sdk测试下,看是否还有500的情况呢?

    经查证问题出自 AlibabaCloud\Dybaseapi\MNS\Requests\BatchReceiveMessage; line:86 88 两个参数错误

    请核实.

    opened by chinayin 12
  • 阿里云一键取号API报 Specified parameter Version is not valid

    阿里云一键取号API报 Specified parameter Version is not valid

    我这边因为项目是php5.6,不能用composer方式引入项目,所以只能去研究阿里云一键取号Api的接口参数去请求, 结果其他请求参数都没有问题,参数Version就报错,https://api.aliyun.com/new?spm=a2c4g.11186623.2.13.2fc27861OpQnPn#/?product=Dypnsapi&version=2017-05-25&api=GetMobile&params={%22RegionId%22:%22cn-hangzhou%22}&tab=DEMO&lang=PHP 这个url里面的version是填 2017-05-25,我也是填这个,结果就报错了。 想问下version参数应该怎么填 image

    opened by 111Quentin 8
  • 内容安全 自定义文本库使用方式?

    内容安全 自定义文本库使用方式?

    • PHP Version: PHP 7.3.21-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Aug 7 2020 14:44:10) ( NTS )
    • Platform: Linux d0aa2e73b694 4.19.76-linuxkit #1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
    • Product: Green
    • Product Version: 20180509
    • API: getSimilarityLibrary addSimilarityLibrary

    您好,我想问下,内容安全 SDK ,创建自定义文本库。是否是 getSimilarityLibrary() 方法。我通过此方法返回状态码 200 , 但是云盾控制台似乎没有?还是说,通过接口创建的文本库在控制台看不到?

    另外,我通过 getSimilarityLibrary 获取报错。

    $body = [
                'ServiceModule' => 'open_api'
            ];
    $body = json_encode($body);
    return \AlibabaCloud\Green\Green::v20180509()->getSimilarityLibrary()->body($body)->request()->toArray();
    

    image

    opened by hedeqiang 6
  • CCS的配置有错?或者CCS的SDK还不完整?

    CCS的配置有错?或者CCS的SDK还不完整?

    你好,我在CCS的配置文件里面发现是这样配置的: 'ccs' => [ 'cn-hangzhou' => 'ccs.aliyuncs.com', ], 但是我在官方文档中看到的URL是这样的:https://cschat-ccs.aliyun.com/openapi/forwardMessage?tntInstId=XXX&scene=YYY&src=outerservice&timestamp=1487230487910&digest=ZZZ

    域名为什么不对?

    另外,官方文档中的forwardMessage、tntInstId在整个SDK中都找不到。

    是不是CCS的SDK还不完整?或者是不是我哪里错了?

    opened by softwarezhu 6
  • STS获取accessToken出师不利

    STS获取accessToken出师不利

    提示:May not yet support product Sts quick access, you can use [Alibaba Cloud Client for PHP] to send any custom requests: https://github.com/aliyun/openapi-sdk-php-client/blob/master/docs/en-US/3-Request.md

    大佬们求救,第一次用阿里云的这种SDK方式。有点懵。如下图所示,提示错误如上图。

    我现在是想WEB上传文件到OSS,目前看文档说是要通过AK的方式来获取令牌环,然后用令牌环来上传文件,就是这个accessToken,卡这一步了。不知道逻辑上对不对,求救。

    opened by huangdengpan 5
  • 无法获取容器镜像服务仓库列表

    无法获取容器镜像服务仓库列表

    • PHP 版本:7.2.6
    • 平台:docker alpine
    • 产品名称:容器镜像服务Cr
    • 产品版本:20160607
    • API:getRepoList

    代码基本是拿官网文档过来后做的修改:

    AlibabaCloud::accessKeyClient('xxx','xxx')->regionId('cn-hangzhou')->asDefaultClient();
    
    try {
    	$options = [
    	    'debug' => true,
    	    'query' => [
    	        'Status' => 'NORMAL',
    	        'RepoNamePrefix' => ''
    	    ]
    	];
    	$request = Cr::v20160607()
    	            ->getRepoList($options);
    
    	$r = $request->request();
    } catch (ServerException $e) {
        echo $e->getResult();
    }
    

    最后捕获打出来的结果是:

    {"RequestId":"806D70E8-32B0-4F18-8C8A-CA54E5D22E2E","HostId":"location.aliyuncs.com","Code":"Illegal Parameter","Message":"Please check the parameters"}
    

    不清楚是哪里参数有误。 而且API文档https://help.aliyun.com/document_detail/72399.html 上还有个RepoNamePrefix参数,要求是必须提供该参数,但SDK中又没有AlibabaCloud\Cr\V20160607\GetRepoList::withRepoNamePrefix()这样的函数,所以我通过options['query']进行了传递,不知道是否正确。

    accessKeyId和accessKeySecret都是正确的 到底哪里出现了参数错误?

    opened by Veitor 5
  • What's the diference between `retryByClient()` and `retryByServer()`?

    What's the diference between `retryByClient()` and `retryByServer()`?

    According to vendor/alibabacloud/client/src/Request/Request.php, a "Server Retry" is calling request() again, and a "Client Retry" is calling response() again. But request() is just resolveOption() + response(). Also, both shouldServerRetry() and shouldClientRetry() determines the status code returned from GuzzleHttp. It seems that they behave the same. So which should I use for ensuring the idempotent (https://help.aliyun.com/document_detail/25693.html)?

    opened by balthild 4
  • vod中ListVodTemplate的TemplateType参数有哪些选项?

    vod中ListVodTemplate的TemplateType参数有哪些选项?

    ListVodTemplate这个接口在新版的aliyun-php-sdk-vod/vod中是ListTranscodeTemplateGroupRequest负责的(我只是从单词意思上分析的),官方文档里也没有ListVodTemplate的介绍,现在都是composer直接安装的,为啥两边不保持一致呢?

    opened by laofu110 4
  • 文档要求php版本>5.6,但实际composer安装后,需要php>7.2

    文档要求php版本>5.6,但实际composer安装后,需要php>7.2

    文档要求php版本>5.6,但实际composer安装后,需要php>7.2 其中依赖的组件明确要求php版本>7.2,可能是组件pcr,因此建议: 1、明确组件版本,尽量降低组件对新版的要求; 2、精确本产品安装后的实际版本需求。

    • PHP Version:php.5.6.38
    • Platform:macos
    • Product: alibabacloud/sdk(sts)
    • Product Version:最新版本
    • API:
    opened by lawyerlaoyang 2
  • When will it be compatible with php8?hurry up!!!

    When will it be compatible with php8?hurry up!!!

    According to the official reply, it is being improved, and it has not been improved for so long,Quite helpless

    Is there another project that will let me use another cloud

    opened by zbuzhi92 2
  • 不支持php8.1

    不支持php8.1

    During inheritance of Countable: Uncaught think\exception\ErrorException: Return type of AlibabaCloud\Client\Result\Result::count($key = null) should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in

    During inheritance of ArrayAccess: Uncaught think\exception\ErrorException: Return type of Adbar\Dot::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/adbario/php-dot-notation/src/Dot.php:510

    主要是php8.1变成强类型.新多接口的类型都要强制输入输出

    opened by bkkkd 3
  • nlp调用一直返回 SignatureDoesNotMatch: Specified signature is not matched with our calculation

    nlp调用一直返回 SignatureDoesNotMatch: Specified signature is not matched with our calculation

    • PHP Version:7.4.3
    • Platform:wsl
    • Product:nlp
    • Product Version:SignatureDoesNotMatch: Specified signature is not matched with our calculation
    • API:
               AlibabaCloud::accessKeyClient($this->accessKeyId, $this->accessKeySecret)
                    ->regionId('cn-hangzhou')
                    ->asDefaultClient();
    
                $res = AlibabaCloud::rpc()
                    ->host('alinlp.cn-hangzhou.aliyuncs.com')
                    ->product('Nlp')
                    ->action('GetWsChGeneral')
                    ->format('JSON')
                    ->method('POST')
                    ->scheme('https')
                    ->options([
                        'query' => [
                            'ServiceCode' => 'alinlp',
                            'Text' => $text,
                            'TokenizerId' => 'GENERAL_CHN',
                            'OutType' => '1',
                            'Version' => '2020-06-29',
                        ]
                    ])->request();
    
    opened by liulianjun1995 0
  •  AlibabaCloud\Tea\Utils\Utils::isUnset(): Argument #1 ($value) cannot be passed by reference

    AlibabaCloud\Tea\Utils\Utils::isUnset(): Argument #1 ($value) cannot be passed by reference

    Error

    AlibabaCloud\Tea\Utils\Utils::isUnset(): Argument #1 ($value) cannot be passed by reference

    at vendor/alibabacloud/darabonba-openapi/src/OpenApiClient.php:726 722▕ $_lastRequest = $_request; 723▕ $_response = Tea::send($_request, $_runtime); 724▕ if (Utils::is4xx($_response->statusCode) || Utils::is5xx($_response->statusCode)) { 725▕ $err = []; ➜ 726▕ if (!Utils::isUnset(@$_response->headers['content-type']) && Utils::equalString(@$_response->headers['content-type'], 'text/xml;charset=utf-8')) { 727▕ $_str = Utils::readAsString($_response->body); 728▕ $respMap = XML::parseXml($_str, null); 729▕ $err = Utils::assertAsMap(@$respMap['Error']);

    opened by s454666-star 0
  • ......

    ......

    第一次用阿里云的 API。 调用个业务第一步:先研究了半天的文档,知道了 openapi 的 demo 里面有源码可以用,找到了,下载对应的 demo,然后看着 demo 里面的垃圾代码,引入“各种版本的”的包,谨慎的抄着命名空间,然后好不容易接完了 V201903xx 的版本 API哈哈哈,这他妈有意思的 API ,想接个人机验证的,去官网文档找半天找到个 afs 业务的 sdk,源码下回来直接吐了,引入的几个类都是废弃的,再想找找是不是还有其他的文档,实在折腾。要不是业务需要,再也不想接 aliyun 了。

    opened by Linij 2
Releases(1.8.1629)
Owner
Alibaba Cloud
More Than Just Cloud
Alibaba Cloud
Supermeteor is PHP SDK use to create cloud message: whatsapp, sms and email etc

Supermeteor Supermeteor is PHP SDK use to create cloud message: whatsapp, sms and email etc How to use install using composer composer require superme

null 0 Jul 15, 2022
Shopware PHP SDK is a simple SDK implementation of Shopware 6 APIs

Shopware PHP SDK is a simple SDK implementation of Shopware 6 APIs. It helps to access the API in an object-oriented way.

Thuong Le 77 Dec 19, 2022
Zoho CRM API SDK is a wrapper to Zoho CRM APIs. By using this sdk, user can build the application with ease

Archival Notice: This SDK is archived. You can continue to use it, but no new features or support requests will be accepted. For the new version, refe

null 81 Nov 4, 2022
This package makes it easy for developers to access WhatsApp Cloud API service in their PHP code.

The first PHP API to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform

NETFLIE 135 Dec 29, 2022
Appwrite configuration for Cloud Function runtimes settings 🌩

Appwrite Runtimes Appwrite repository for Cloud Function runtimes that contains the configurations and tests for all of the Appwrite runtime environme

Appwrite 39 Nov 22, 2022
The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructure and leverage the power of 1Password Secrets Automation

1Password Connect PHP SDK The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructu

Michelangelo van Dam 12 Dec 26, 2022
Facebook SDK for PHP (v6) - allows you to access the Facebook Platform from your PHP app

Facebook SDK for PHP (v6) This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app. Installa

null 0 Aug 10, 2022
Unofficial Firebase Admin SDK for PHP

Firebase Admin PHP SDK Table of Contents Overview Installation Documentation Support License Overview Firebase provides the tools and infrastructure y

kreait 1.9k Jan 3, 2023
Notion PHP SDK

Notion PHP SDK This is an unofficial PHP SDK for the new public Notion API. It's work in progress as we didn't get the change to be included to the pr

Codecycler 43 Nov 29, 2022
爱发电非官方简易 PHP SDK

afdian-php-sdk 爱发电非官方简易 PHP SDK by Akkariin 这是一个简单的 SDK,可以用于查询爱发电的订单和赞助者信息 Installation 将项目 clone 到本地即可 git clone https://github.com/ZeroDream-CN/afdi

ZeroDream-CN 17 Nov 7, 2022
AWS Cognito package using the AWS SDK for PHP/Laravel

Laravel Package to manage Web and API authentication with AWS Cognito AWS Cognito package using the AWS SDK for PHP This package provides a simple way

EllaiSys 74 Nov 15, 2022
PHP SDK to interact with the Casper Network nodes via RPC

casper-php-sdk PHP SDK to interact with Casper Network nodes via RPC Install composer require make-software/casper-php-sdk Examples RPC Client: $node

MAKE Technology LLC 7 May 8, 2022
A Laravel 5+ (and 4) service provider for the AWS SDK for PHP

AWS Service Provider for Laravel 5/6/7/8 This is a simple Laravel service provider for making it easy to include the official AWS SDK for PHP in your

Amazon Web Services 1.5k Dec 28, 2022
A complete Notion SDK for PHP developers.

notion-sdk-php A complete Notion SDK for PHP developers. Installation composer require mariosimao/notion-php Getting started A Notion token will be n

Mario Simão 77 Nov 29, 2022
SDK of the LINE Login API for PHP

LINE Login for PHP SDK of the LINE Login API for PHP Documentation See the official API documentation for more information. Installation Use the packa

null 4 Sep 15, 2022
PHP SDK - Flexie CRM fiskalizimi solution

PHP SDK - Flexie CRM fiskalizimi solution Fiskalizimi PHP SDK allows you to talk and generate your e-invoices programmatically from your own solution

Flexie CRM 3 Dec 30, 2021
PHP Digital Green Certificate SDK

Digital Green Certificate SDK PHP Indice Contesto Installazione Uso Licenza Dettaglio licenza Contesto Attenzione, questo repository è derivato dalle

null 13 Jun 20, 2022
Esse SDK em PHP foi desenvolvido no intuito de tornar mais prático a integração com nossa API.

Sobre Beedoo SDK Acessar documentação completa da Beedoo API. A API é organizada seguindo a arquitetura REST, boas práticas, convenções e padrões como

Beedoo Edtech 5 Dec 2, 2021
A PHP SDK for accessing the OpenAI GPT-3 API

OpenAI GPT-3 Api Client in PHP Installation You can install the package via composer: composer require orhanerday/open-ai Usage use Orhanerday\OpenAi\

Orhan erday 462 Jan 2, 2023