edit-icon download-icon

Quick start

Last Updated: Apr 19, 2018

Procedure

  1. Create AcsClient instance.

    1. $clientProfile = DefaultProfile::getProfile(
    2. $mps_region_id, # Your Region ID
    3. $access_key_id, # Your AccessKey ID
    4. $access_key_secret # Your AccessKey Secret
    5. );
    6. $client = new DefaultAcsClient($clientProfile);
  2. Create request and set parameters.

    1. $request = new Mts\SubmitJobsRequest();
    2. $request->setAcceptFormat('JSON');
  3. Initiate API request and display returned value.

    1. $response = $client->getAcsResponse($request);
    2. print 'PipelineName is:' . $response->{'PipelineList'}->{'Pipeline'}[0]->{'Name'} . "\n";
    3. print 'PipelineId is:' . $response->{'PipelineList'}->{'Pipeline'}[0]->{'Id'} . "\n";

Full code

  1. <?php
  2. include_once 'aliyun-openapi-php-sdk/aliyun-php-sdk-core/Config.php';
  3. use Mts\Request\V20140618 as Mts;
  4. $access_key_id = 'xxx';
  5. $access_key_secret = 'xxx';
  6. $mps_region_ids = array('cn-hangzhou', 'cn-beijing', 'cn-shenzhen',
  7. 'cn-shanghai', 'cn-hongkong', 'us-west-1',
  8. 'ap-southeast-1', 'ap-northeast-1', 'eu-central-1',
  9. 'ap-south-1');
  10. foreach ($mps_region_ids as $mps_region_id) {
  11. print 'region is:' . $mps_region_id . "\n";
  12. # Create DefaultAcsClient instance and complete initialization
  13. $clientProfile = DefaultProfile::getProfile(
  14. $mps_region_id, # Your Region ID
  15. $access_key_id, # Your AccessKey ID
  16. $access_key_secret # Your AccessKey Secret
  17. );
  18. $client = new DefaultAcsClient($clientProfile);
  19. # Create API request and set parameters
  20. $request = new Mts\SearchPipelineRequest();
  21. # Initiate request and handle the returned value
  22. try {
  23. $response = $client->getAcsResponse($request);
  24. print 'PipelineName is:' . $response->{'PipelineList'}->{'Pipeline'}[0]->{'Name'} . "\n";
  25. print 'PipelineId is:' . $response->{'PipelineList'}->{'Pipeline'}[0]->{'Id'} . "\n";
  26. } catch(ServerException $e) {
  27. print 'Error: ' . $e->getErrorCode() . ' Message: ' . $e->getMessage() . "\n";
  28. } catch(ClientException $e) {
  29. print 'Error: ' . $e->getErrorCode() . ' Message: ' . $e->getMessage() . "\n";
  30. }
  31. }
Thank you! We've received your feedback.