Environment requirements
PHP 5.3+
Installation
Download the sourcecode of the SDK forPHP from GitHub.
Copy the aliyun-php-sdk-core and aliyun-php-sdk-mts folders to your project, and place them in the same directory.
Edit aliyun-php-sdk-core/Config.php.
Locate “//config sdk auto load path.” and add the following content following this line:
Autoloader::addAutoloadPath("aliyun-php-sdk-mts");
Multi-region support
Edit aliyun-php-sdk-core/Regions/endpoints.xml, and add the Beijing region before the last line (
</Endpoints>
) (add other regions in a similar way).<Endpoint name="mts-cn-beijing">
<RegionIds>
<RegionId>mts-cn-beijing</RegionId>
</RegionIds>
<Products>
<Product>
<ProductName>Mts</ProductName>
<DomainName>mts.cn-beijing.aliyuncs.com</DomainName>
</Product>
</Products>
</Endpoint>
API call example
The following calls
SearchMediaWorkflow
as an example. The most important is to set the attribute of RegionId of $request. The setting for other API calls is similar.include_once 'aliyun-php-sdk-core/Config.php';
use Mts\Request\V20140618 as Mts;
function search_media_workflow($client, $regionId)
{
$request = new Mts\SearchMediaWorkflowRequest();
$request->setAcceptFormat('JSON');
$request->setRegionId($regionId); //Important
$response = $client->getAcsResponse($request);
return $response;
}
Call examples of APIs in the Hangzhou region
include_once 'aliyun-php-sdk-core/Config.php';
$profile = DefaultProfile::getProfile('cn-hangzhou',
$access_key_id,
$access_key_secret);
$client = new DefaultAcsClient($profile);
search_media_workflow($client, 'cn-hangzhou');
Call examples of APIs in the Beijing region
include_once 'aliyun-php-sdk-core/Config.php';
$profile = DefaultProfile::getProfile('mts-cn-beijing',
$access_key_id,
$access_key_secret);
$client = new DefaultAcsClient($profile);
search_media_workflow($client, 'mts-cn-beijing');