GithubHelp home page GithubHelp logo

aliyun / openapi-sdk-php-client Goto Github PK

View Code? Open in Web Editor NEW
219.0 7.0 54.0 1.61 MB

Official repository of the Alibaba Cloud Client for PHP

Home Page: https://packagist.org/packages/alibabacloud/client

License: Other

PHP 100.00%
alibaba alibabacloud client composer php aliyun sdk cloud region

openapi-sdk-php-client's Introduction

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:

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

<?php

use AlibabaCloud\Client\AlibabaCloud;

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

<?php

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

try {
    $result = AlibabaCloud::roa()
                          ->regionId('cn-hangzhou') // Specify the requested regionId, if not specified, use the client regionId, then default regionId
                          ->product('CS') // Specify product
                          ->version('2015-12-15') // Specify product version
                          ->action('DescribeClusterServices') // Specify product interface
                          ->serviceCode('cs') // Set ServiceCode for addressing, optional
                          ->endpointType('openAPI') // Set type, optional
                          ->method('GET') // Set request method
                          ->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
                          ->pathPattern('/clusters/[ClusterId]/services') // Specify path rule with ROA-style
                          ->withClusterId('123456') // Assign values to parameters in the path. Method: with + Parameter
                          ->request(); // Make a request and return to result object. The request is to be placed at the end of the setting
                          
    print_r($result->toArray());
    
} catch (ClientException $exception) {
    print_r($exception->getErrorMessage());
} catch (ServerException $exception) {
    print_r($exception->getErrorMessage());
}

RPC Request

<?php

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

try {
    $result = AlibabaCloud::rpc()
                          ->product('Cdn')
                          ->version('2014-11-11')
                          ->action('DescribeCdnService')
                          ->method('POST')
                          ->request();
    
    print_r($result->toArray());
    
} catch (ClientException $exception) {
    print_r($exception->getErrorMessage());
} catch (ServerException $exception) {
    print_r($exception->getErrorMessage());
}

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.

openapi-sdk-php-client's People

Contributors

aliguyong avatar axiosleo avatar jacksontian avatar peze avatar sdk-team avatar yndu13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

openapi-sdk-php-client's Issues

InvalidAction.NotFound: Specified api is not found

框架:Laravel6.x
PHP版本:7.3.11
SDK:图像搜索 ImageSearch

AlibabaCloud::accessKeyClient(env('ALI_IMAGE_KEY'), env('ALI_IMAGE_SECRET'))
    ->regionId('cn-shanghai')
    ->asDefaultClient();

$request = AlibabaCloud::roa()
    ->product('ImageSearch')
    ->method('POST')
    ->version('2019-03-25')
    ->action('SearchImage')
    ->options([
        'query' => [
            'PicContent' => 'test'
        ]
    ])
    ->timeout(10)
    ->request();

InvalidAction.NotFound: Specified api is not found, please check your url and method. RequestId: 5B2C3075-5D8C-410C-8077-B87DE19E2FAB POST "http://imagesearch.cn-shanghai.aliyuncs.com/?Date=2020-3-15&PicContent=test&Version=2019-03-25\" 404

Encode内 func toString() 导致使用邮件sdk发送时签名失败

本人花了好几个小时,才意识到,不是自己写的问题,也不是sdk的问题,特地比对了好几个client版本,终于发现🤮❄️

        // 当前版本 签名失败
        foreach ($this->data as $key => $value) {
            $encode = rawurlencode($value);
            if ($encode === '') {
                $string .= "$key&";
            } else {
                $string .= "$key=$encode&";
            }
        }

        // v1.5.18 签名成功
        foreach ($this->data as $key => $value) {
            $encode = rawurlencode($value);
            $string .= "$key=$encode&";
        }

带空字符串参数的请求会出现签名错误

  • PHP 版本:7.1-7.4
  • 平台:Linux
  • 产品名称:Vod视频直播
  • 产品版本:1.4.25+
  • API:任何API
$query = [
  'Title' => 'Title',
  'Description' => '', // 只要是空的就会报签名错误
  'FileName' => 'test.mp4',
];
$request = Vod::v20170321()->createUploadVideo([
  'query' => $query,
])->endpoint($endpoint)
  ->request();

这个问题从1.5.25开始出现

能提供精简版么

我就是要集成个短信接口,整个项目不超过100个文件,咱们的sdk弄下来就 600多个文件。真是有些难以接受

请问该sdk对swoole的协程环境支持友好吗?

您的功能请求是否与问题有关? 请描述一下。
请描述您要解决的问题。

描述你想要的解决方案
请描述所需的行为。

描述您考虑过的替代方案
请描述您考虑的替代解决方案或功能。

版本号 在哪里获取??

Specified parameter Version is not valid.
每次都报错这个. 具体的版本号 产品名称 在哪里查????

open_basedir 报错

is_file(): open_basedir restriction in effect. File(/home/www/.alibabacloud/credentials) is not within the allowed path(s)

类名跟方法换了为啥不更新大版本号

不是害人么,你更改了使用类名跟方法难点不知道换个大版本号或者新建分支么,这么大的一个厂犯这种错么?我说怎么composer了一下视频啥的一直报错呢,另外,在文档中给建议安装语句的时候带上版本号约束

使用composer require alibabacloud/client指令失败

PHP版本:7.4.16
平台:Linux Centos 8

报错内容

Installation failed, deleting ./composer.json.                                                                       
  [Seld\JsonLint\ParsingException]                                                                     
  "https://mirrors.aliyun.com/composer/p2/symfony/polyfill-mbstring.json" does not contain valid JSON  
  Parse error on line 1:                                                                               
<html><head>    <                                                                                  
  -^                                                                                                   
  Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[' 

依赖库版本太老

Is your feature request related to a problem? Please describe.
依赖库clagiordano/weblibs-configmanager依赖的symfony/yaml ^2.8版本太老了,并且在SDK中并不需要依赖yaml。

src/Config/Config.php 中使用了ConfigManager对象,看了clagiordano/weblibs-configmanager的源代码ConfigManager对象不需要依赖symfony/yaml,只有YamlConfigManager才需要依赖symfony/yaml,所以SDK并不需要yaml扩展。

Describe the solution you'd like
如果clagiordano/weblibs-configmanager无法更新的话希望替换掉这个依赖。

Describe alternatives you've considered
我暂时fork了clagiordano/weblibs-configmanager,修改了symfony/yaml 的版本,然后再主项目的composer.json使用replace替换为fork的版本。

当使用 debug 日志时 Result 数据被清空

\AlibabaCloud\Client\Result\Result::resolveData 函数中使用

$content = $this->getBody()->getContents();

这个方法当 body 被输出过就只能获取到空字符串,应该使用 (string) $this->getBody()

不想使用 AlibabaCloud 助手类

您的功能请求是否与问题有关? 请描述一下。

描述你想要的解决方案

能否直接把 Client 对象传递给 Request 啊?非要整个 name, 非要用 AlibabaCloud 助手,感觉一点不香,语义也不是很清楚

描述您考虑过的替代方案
继承 Request 类,覆盖父类方法

你好。

My composer.json:

...replace me...

Output of composer diagnose:

...replace me...

When I run this command:

...replace me...

I get the following output:

...replace me...

And I expected this to happen:

...replace me...

PHP 8 兼容问题

  • PHP 版本:8.1.4
  • 平台:macOS
  • 产品名称:STS
  • 产品版本:2015-04-01
  • API:GetCallerIdentity/AssumeRole
PHP Deprecated:  Return type of AlibabaCloud\Client\Request\Request::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /vendor/alibabacloud/client/src/Traits/ArrayAccessTrait.php on line 45

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.