This topic describes how to use Image Search SDK for PHP and provides sample code.

Methods

Method Description
Add Adds one or more images.
SearchImageByPic Searches for similar images based on an image.
SearchImageByName Searches for similar images based on the name of an existing image in the image gallery.
Delete Deletes one or more images.
Update Updates image information.
Detail Queries instance information.
DumpMeta Creates a task to export metadata.
DumpMetaList Queries the tasks that are used to export metadata.
BatchTask Creates a batch task.
BatchTaskList Queries the tasks that are used to perform batch operations.

Preparations

Before you install and use an Alibaba Cloud SDK, make sure that you have created an Alibaba Cloud account and obtained the AccessKey pair of the Alibaba Cloud account. For more information, see Obtain an AccessKey pair.

Note The version of PHP must be 5.5 or later.

Obtain Composer from the Alibaba Cloud mirror:

https://developer.aliyun.com/composer
Install dependencies
  • Use Composer to obtain Image Search SDK for PHP.
    composer require alibabacloud/imagesearch-20201214
  • Use the composer.json file.
    {
       "require": {
           "alibabacloud/imagesearch-20201214": "^4.0"    
        }
    }
The following sample code shows the dependency-related information:
declare (strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use AlibabaCloud\SDK\ImageSearch\V20201214\ImageSearch;
use AlibabaCloud\SDK\ImageSearch\V20201214\Models\AddImageAdvanceRequest;
use AlibabaCloud\SDK\ImageSearch\V20201214\Models\SearchImageByPicAdvanceRequest;
use AlibabaCloud\SDK\ImageSearch\V20201214\Models\SearchImageByNameRequest;
use AlibabaCloud\SDK\ImageSearch\V20201214\Models\DeleteImageRequest;
use AlibabaCloud\SDK\ImageSearch\V20201214\Models\UpdateImageRequest;
use AlibabaCloud\SDK\ImageSearch\V20201214\Models\DetailRequest;
use AlibabaCloud\SDK\ImageSearch\V20201214\Models\DumpMetaRequest;
use AlibabaCloud\SDK\ImageSearch\V20201214\Models\DumpMetaListRequest;
use AlibabaCloud\SDK\ImageSearch\V20201214\Models\IncreaseInstanceRequest;
use AlibabaCloud\SDK\ImageSearch\V20201214\Models\IncreaseListRequest;
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use GuzzleHttp\Psr7\Stream;

Add

  • Sample code
    function _addImage()
    {
        $config = new Config();
        $config->accessKeyId = "<accessKeyId>";
        $config->accessKeySecret = "<accessKeySecret>";
        $config->regionId = "<regionId>";
        $config->endpoint = "imagesearch.[regionId].aliyuncs.com";
        $client = new ImageSearch($config);
        $request = new AddImageAdvanceRequest();
        // Required. The name of the Image Search instance. 
        $request->instanceName = "xxxxxx";
        // Required. The ID of the product. The ID cannot exceed 512 characters in length. 
        // A product ID can correspond to multiple image names. 
        $request->productId = "testPhp";
        // Required. The name of the image. The name cannot exceed 512 characters in length. 
        // 1. Required. An image is uniquely identified by the values of the ProductId and PicName parameters. 
        // 2. If you add an image whose product ID (ProductId) and image name (PicName) are the same as those of an existing image, the newly added image overwrites the existing image. 
        $request->picName = "testPhp";
        // Optional. The ID of the product category. 
        // 1. For product search: If a category is specified, the specified category prevails. If no category is specified, the system estimates and selects a category. The category selected by the system is included in the response. 
        // 2. For cloth, brand, and generic image searches: The category ID is set to 88888888 regardless of whether a category ID is set. 
        $request->categoryId = 3;
        // Optional. The user-defined content. The value can be up to 4,096 characters in length. 
        // If you set this parameter, the response includes this parameter and its value. You can add text such as an image description. 
        $request->customContent = "this is a simple test";
        // Optional. The attribute of the INT type. The attribute can be used to filter images in image searches. If you set this parameter, the response includes this parameter and its value. 
        // For example, you can set different attributes for images from different sites or different users. This way, users can filter images by attribute and obtain more accurate search results.
        $request->intAttr = 56;
        // Optional. The attribute of the STRING type. The value cannot exceed 128 characters in length. The attribute can be used to filter images in image searches. If you set this parameter, the response includes this parameter and its value. 
        $request->strAttr = "test";
        // Optional. Specifies whether to recognize the subject in the image. Default value: true. 
        // 1. If you set this parameter to true, the system recognizes the subject in the image, and searches for images based on the recognized subject. The response includes the recognition result. 
        // 2. If you set this parameter to false, the system searches for images based on the entire image without subject recognition. 
        // 3. For cloth image searches, this parameter does not take effect. The system searches for images based on the entire image. 
        $request->crop = true;
        // Optional. The subject area of the image, in the format of x1,x2,y1,y2. Specifically, x1 and y1 specify the upper-left pixel, and x2 and y2 specify the lower-right pixel. The specified region cannot cross the boundary of the image. 
        // If you set the Region parameter, the search is conducted based on the value of the Region parameter regardless of the value of the Crop parameter. 
        // For cloth image searches, this parameter does not take effect. The system searches for images based on the entire image. 
        $request->region = "167,467,221,407";
        // The image. The image cannot exceed 4 MB in size. The transmission timeout period is 5 seconds. Only the following image formats are supported: PNG, JPG, JPEG, BMP, GIF, WebP, TIFF, and PPM.
        // For product, brand, and generic images, the length and the width of the image must range from 100 pixels to 4,096 pixels.
        // For cloth images, the length and the width of the image must range from 448 pixels to 4,096 pixels.
        // The image cannot contain rotation properties.
        $request->picContentObject = new Stream(fopen("<filePath>", 'r+'));
          
        $runtime = new RuntimeOptions();
        $runtime->maxIdleConns = 3;
        $runtime->connectTimeout = 3000;
        $runtime->readTimeout = 3000;
        try {
            $response = $client->addImageAdvance($request, $runtime);
            var_dump($response->toMap());
          } catch (TeaUnableRetryError $e) {
            var_dump($e->getLastException(), $e->getLastRequest());
        } 
    }
  • Sample responses
    {
      ["requestId"]=>
      string(36) "242CB8B7-DD36-42ED-9A76-37915DC7ED81"
      ["success"]=>
      bool(true)
      ["message"]=>
      string(7) "success"
      ["code"]=>
      int(0)
      ["picInfo"]=>
      array(2) {
        ["CategoryId"]=>
        int(0)
        ["Region"]=>
        string(15) "167,477,221,407"
      }
      ["_name":protected]=>
      array(5) {
        ["requestId"]=>
        string(9) "RequestId"
        ["success"]=>
        string(7) "Success"
        ["message"]=>
        string(7) "Message"
        ["code"]=>
        string(4) "Code"
        ["picInfo"]=>
        string(7) "PicInfo"
      }
      ["_required":protected]=>
      array(0) {
      }
    }

SearchImageByPic

  • Sample code
    function _getImageByPic()
    {
        $config = new Config();
        $config->accessKeyId = "<accessKeyId>";
        $config->accessKeySecret = "<accessKeySecret>";
        $config->regionId = "<regionId>";
        $config->endpoint = "imagesearch.[regionId].aliyuncs.com";
        $client = new ImageSearch($config);
        $request = new SearchImageByPicAdvanceRequest();
        // Required. The name of the Image Search instance. 
        $request->instanceName = "xxxxx";    
        // The image. The image cannot exceed 4 MB in size. The transmission timeout period is 5 seconds. Only the following image formats are supported: PNG, JPG, JPEG, BMP, GIF, WebP, TIFF, and PPM.
        // For product, brand, and generic images, the length and the width of the image must range from 100 pixels to 4,096 pixels.
        // For cloth images, the length and the width of the image must range from 448 pixels to 4,096 pixels.
        // The image cannot contain rotation properties.
        $imageStream = new Stream(fopen("<filePath>", 'r+'));    
        // Optional. The ID of the product category. 
        // 1. For product search: If a category is specified, the specified category prevails. If no category is specified, the system estimates and selects a category. The category selected by the system is included in the response. 
        // 2. For cloth, brand, and generic image searches: The category ID is set to 88888888 regardless of whether a category ID is set. 
        $request->categoryId = 3;
        // 1. If you set this parameter to true, the system recognizes the subject in the image, and searches for images based on the recognized subject. The response includes the recognition result. 
        // 2. If you set this parameter to false, the system searches for images based on the entire image without subject recognition. 
        // 3. For cloth image searches, this parameter does not take effect. The system searches for images based on the entire image. 
        $request->crop = true;
        // Optional. The subject area of the image, in the format of x1,x2,y1,y2. Specifically, x1 and y1 specify the upper-left pixel, and x2 and y2 specify the lower-right pixel. The specified region cannot cross the boundary of the image. 
        // If you set the Region parameter, the search is conducted based on the value of the Region parameter regardless of the value of the Crop parameter. 
        // For cloth image searches, this parameter does not take effect. The system searches for images based on the entire image. 
        $request->region = "167,467,221,407";
        // Optional. int_attr supports the following operators: >, >=, <, <=, and =. str_attr supports the = and != operators. You can set the logical operator between conditions to AND or OR. 
        // Examples:
        // 1. Filter images based on IntAttr: int_attr>=100.
        // 2. Filter images based on StrAttr: str_attr!="value1".
        // 3. Filter images based on int_attr and str_attr fields: int_attr=1000 AND str_attr="value1".
        $request->filter = "int_attr=56 AND str_attr =\"test\"";
        $request->picContentObject = $imageStream;
        $runtime = new RuntimeOptions();
        $runtime->maxIdleConns = 3;
        $runtime->connectTimeout = 3000;
        $runtime->readTimeout = 3000;
        try {
            $response = $client->searchImageByPicAdvance($request, $runtime);
            var_dump($response->toMap());
        } catch (TeaUnableRetryError $e) {
            var_dump($e->getLastException(), $e->getLastRequest());
        } catch (Exception $e) {
        }
    }
  • Sample responses
    {
      ["requestId"]=>
      string(36) "453517A3-7D00-476E-A946-8CC3B9DC6FA1"
      ["success"]=>
      bool(true)
      ["code"]=>
      int(0)
      ["msg"]=>
      string(7) "success"
      ["auctions"]=>
      array(5) {
        [0]=>
        array(4) {
          ["CategoryId"]=>
          int(0)
          ["PicName"]=>
          string(7) "vae.jpg"
          ["ProductId"]=>
          string(4) "1000"
          ["SortExprValues"]=>
          string(22) "7.33136443711219e+24;0"
          ["Score"]=>
          float(1)
        }
        [1]=>
        array(4) {
          ["CategoryId"]=>
          int(0)
          ["PicName"]=>
          string(4) "test"
          ["ProductId"]=>
          string(4) "test"
          ["SortExprValues"]=>
          string(22) "7.33136443711219e+24;0"
          ["Score"]=>
          float(1)
        }
      ........
        [4]=>
        array(4) {
          ["CategoryId"]=>
          int(0)
          ["PicName"]=>
          string(4) "test"
          ["ProductId"]=>
          string(4) "1000"
          ["SortExprValues"]=>
          string(22) "7.33136443711219e+24;0"
          ["Score"]=>
          float(1)
        }
      }
      ["head"]=>
      array(3) {
        ["DocsFound"]=>
        int(5)
        ["DocsReturn"]=>
        int(5)
        ["SearchTime"]=>
        int(171)
      }
      ["picInfo"]=>
      array(3) {
        ["CategoryId"]=>
        int(0)
        ["MultiRegion"]=>
          array(1) {
            [0]=>
            array(1) {
              ["Region"]=>
              string(15) "134,705,187,785"
            }
         }
        ["AllCategories"]=>
        array(14) {
          [0]=>
          array(2) {
            ["Id"]=>
            int(0)
            ["Name"]=>
            string(4) "Tops"
          }
      ........
          [13]=>
          array(2) {
            ["Id"]=>
            int(88888888)
            ["Name"]=>
            string(5) "Other"
          }
        }
        ["Region"]=>
        string(15) "167,477,221,407"
      }
      ["_name":protected]=>
      array(7) {
        ["requestId"]=>
        string(9) "RequestId"
        ["success"]=>
        string(7) "Success"
        ["code"]=>
        string(4) "Code"
        ["msg"]=>
        string(3) "Msg"
        ["auctions"]=>
        string(8) "Auctions"
        ["head"]=>
        string(4) "Head"
        ["picInfo"]=>
        string(7) "PicInfo"
      }
      ["_required":protected]=>
      array(0) {
      }
    }

SearchImageByName

  • Sample code
    function _getImageByName()
    {
        $config = new Config();
        $config->accessKeyId = "<accessKeyId>";
        $config->accessKeySecret = "<accessKeySecret>";
        $config->regionId = "<regionId>";
        $config->endpoint = "imagesearch.[regionId].aliyuncs.com";
        $client = new ImageSearch($config);
        $request = new SearchImageByNameRequest();
        // Required. The name of the Image Search instance. 
        $request->instanceName = "xxxxxxx";
        // Required. The ID of the product. The ID cannot exceed 512 characters in length. 
        // A product ID can correspond to multiple image names. 
        $request->productId = "testPhp";
        // Required. The name of the image. The name cannot exceed 512 characters in length. 
        // 1. Required. An image is uniquely identified by the values of the ProductId and PicName parameters. 
        // 2. If you add an image whose product ID (ProductId) and image name (PicName) are the same as those of an existing image, the newly added image overwrites the existing image. 
        $request->picName = "testPhp";    
        // Optional. The ID of the product category. 
        // 1. For product search: If a category is specified, the specified category prevails. If no category is specified, the system estimates and selects a category. The category selected by the system is included in the response. 
        // 2. For cloth, brand, and generic image searches: The category ID is set to 88888888 regardless of whether a category ID is set. 
        $request->categoryId = 3;
        // 1. If you set this parameter to true, the system recognizes the subject in the image, and searches for images based on the recognized subject. The response includes the recognition result. 
        // 2. If you set this parameter to false, the system searches for images based on the entire image without subject recognition. 
        // 3. For cloth image searches, this parameter does not take effect. The system searches for images based on the entire image. 
        $request->crop = true;
        // Optional. The subject area of the image, in the format of x1,x2,y1,y2. Specifically, x1 and y1 specify the upper-left pixel, and x2 and y2 specify the lower-right pixel. The specified region cannot cross the boundary of the image. 
        // If you set the Region parameter, the search is conducted based on the value of the Region parameter regardless of the value of the Crop parameter. 
        // For cloth image searches, this parameter does not take effect. The system searches for images based on the entire image. 
        $request->region = "167,467,221,407";
        // Optional. int_attr supports the following operators: >, >=, <, <=, and =. str_attr supports the = and != operators. You can set the logical operator between conditions to AND or OR. 
        // Examples:
        // 1. Filter results based on IntAttr: int_attr>=100.
        // 2. Filter results based on str_attr!="value1".
        // 3. Filter images based on int_attr and str_attr fields: int_attr=1000 AND str_attr="value1"
        $request->filter = "int_attr=56 AND str_attr =\"test\"";
     
        try {
            $response = $client->SearchImageByName($request);
            var_dump($response->toMap());
        } catch (TeaUnableRetryError $e) {
            var_dump($e->getLastException(), $e->getLastRequest());
        } catch (Exception $e) {
        }
    }
  • Sample responses
    ["requestId"]=>
      string(36) "9248A5FC-97AB-4A96-8764-C771CF61D9A1"
      ["success"]=>
      bool(true)
      ["code"]=>
      int(0)
      ["msg"]=>
      string(7) "success"
      ["auctions"]=>
      array(5) {
        [0]=>
        array(4) {
          ["CategoryId"]=>
          int(0)
          ["PicName"]=>
          string(7) "vae.jpg"
          ["ProductId"]=>
          string(4) "1000"
          ["SortExprValues"]=>
          string(22) "7.33136443711219e+24;0"
          ["Score"]=>
          float(1)
        }
      ........
        [4]=>
        array(4) {
          ["CategoryId"]=>
          int(0)
          ["PicName"]=>
          string(4) "test"
          ["ProductId"]=>
          string(4) "1000"
          ["SortExprValues"]=>
          string(22) "7.33136443711219e+24;0"
          ["Score"]=>
          float(1)
        }
      }
      ["head"]=>
      array(3) {
        ["DocsFound"]=>
        int(5)
        ["DocsReturn"]=>
        int(5)
        ["SearchTime"]=>
        int(21)
      }
      ["picInfo"]=>
      array(2) {
        ["CategoryId"]=>
        int(0)
        ["MultiRegion"]=>
          array(1) {
            [0]=>
            array(1) {
              ["Region"]=>
              string(15) "134,705,187,785"
            }
        }
        ["AllCategories"]=>
        array(14) {
          [0]=>
          array(2) {
            ["Id"]=>
            int(0)
            ["Name"]=>
            string(4) "Tops"
          }
          ........
          [13]=>
          array(2) {
            ["Id"]=>
            int(88888888)
            ["Name"]=>
            string(5) "Other"
          }
        }
      }
      ["_name":protected]=>
      array(7) {
        ["requestId"]=>
        string(9) "RequestId"
        ["success"]=>
        string(7) "Success"
        ["code"]=>
        string(4) "Code"
        ["msg"]=>
        string(3) "Msg"
        ["auctions"]=>
        string(8) "Auctions"
        ["head"]=>
        string(4) "Head"
        ["picInfo"]=>
        string(7) "PicInfo"
      }
      ["_required":protected]=>
      array(0) {
      }
    }

Delete

  • Sample code
    function _deleteImage()
    {
        $config = new Config();
        $config->accessKeyId = "<accessKeyId>";
        $config->accessKeySecret = "<accessKeySecret>";
        $config->regionId = "<regionId>";
        $config->endpoint = "imagesearch.[regionId].aliyuncs.com";
        $client = new ImageSearch($config);
        $request = new DeleteImageRequest();
        // Required. The name of the Image Search instance. 
        $request->instanceName = "xxxxxx";
        // Required. The name of the image. The name cannot exceed 512 characters in length. 
        // 1. Required. An image is uniquely identified by the values of the ProductId and PicName parameters. 
        $request->productId = "test";
        // 2. Optional. The name of the image. If you do not set this parameter, the system deletes all the images that are related to the specified product ID. If you set this parameter, the system deletes only the image that is specified by the product_id and pic_name parameters. 
        $request->picName = "test";
          
        try {
            $response = $client->deleteImage($request);
            var_dump($response->toMap());
        } catch (TeaUnableRetryError $e) {
            var_dump($e->getLastException(), $e->getLastRequest());
          } catch (Exception $e) {
        }
    }
  • Sample responses
    {
      ["requestId"]=>
      string(36) "052ECD87-933D-4E65-94F7-F0C0947E41A1"
      ["success"]=>
      bool(true)
      ["message"]=>
      string(7) "success"
      ["code"]=>
      int(0)
      ["_name":protected]=>
      array(4) {
        ["requestId"]=>
        string(9) "RequestId"
        ["success"]=>
        string(7) "Success"
        ["message"]=>
        string(7) "Message"
        ["code"]=>
        string(4) "Code"
      }
      ["_required":protected]=>
      array(0) {
      }
    }

Update

  • Sample code
    function _updateImage()
    {
        $config = new Config();
        $config->accessKeyId = "<accessKeyId>";
        $config->accessKeySecret = "<accessKeySecret>";
        $config->regionId = "<regionId>";
        $config->endpoint = "imagesearch.[regionId].aliyuncs.com";
        $client = new ImageSearch($config);
        $request = new UpdateImageRequest();
        // Required. The name of the Image Search instance. 
        $request->instanceName = "xxxxxx";
        // Required. The ID of the product. The product ID cannot be changed. 
        $request->productId = "1";
        // Required. The name of the image. The image name cannot be changed. 
        $request->picName = "1";
        // Optional. The attribute of the INT type. The attribute can be used to filter images in image searches. If you set this parameter, the response includes this parameter and its value. 
        $request->intAttr = 10;
        // Optional. The attribute of the STRING type. The value cannot exceed 128 characters in length. The attribute can be used to filter images in image searches. If you set this parameter, the response includes this parameter and its value. 
        $request->strAttr = "test";
        // Optional. The user-defined content. The value can be up to 4,096 characters in length. 
        $request->customContent = "This is a sample description";
          
        try {
            $response = $client->updateImage($request);
            var_dump($response->body->toMap());
        } catch (TeaUnableRetryError $e) {
            var_dump($e->getLastException(), $e->getLastRequest());
          } catch (Exception $e) {
        }
    }
  • Sample responses
    array(3) {
      ["Code"]=>
      int(0)
      ["RequestId"]=>
      string(36) "2CD69717-846D-167A-89AD-647213332248"
      ["Success"]=>
      bool(true)
    }

Detail

  • Sample code
    function _detail()
    {
        $config = new Config();
        $config->accessKeyId = "<accessKeyId>";
        $config->accessKeySecret = "<accessKeySecret>";
        $config->regionId = "<regionId>";
        $config->endpoint = "imagesearch.[regionId].aliyuncs.com";
        $client = new ImageSearch($config);
        $request = new DetailRequest();
        // Required. The name of the Image Search instance. 
        $request->instanceName = "xxxxxx";
          
        try {
            $response = $client->detail($request);
            var_dump($response->body->toMap());
        } catch (TeaUnableRetryError $e) {
            var_dump($e->getLastException(), $e->getLastRequest());
          } catch (Exception $e) {
        }
    }
  • Sample responses
    array(3) {
      ["Instance"]=>
      array(8) {
        ["Capacity"]=>
        int(10)
        ["Name"]=>
        string(19) "xxxxxxx"
        ["Qps"]=>
        int(1)
        ["Region"]=>
        string(11) "cn-shanghai"
        ["ServiceType"]=>
        int(0)
        ["TotalCount"]=>
        int(99999)
        ["UtcCreate"]=>
        int(1620382716000)
        ["UtcExpireTime"]=>
        int(1623081600000)
      }
      ["RequestId"]=>
      string(36) "41465B01-11B4-149D-BB6F-BB498B3C39F0"
      ["Success"]=>
      bool(true)
    }

DumpMeta

  • Sample code
    function _dumpMeta()
    {
        $config = new Config();
        $config->accessKeyId = "<accessKeyId>";
        $config->accessKeySecret = "<accessKeySecret>";
        $config->regionId = "<regionId>";
        $config->endpoint = "imagesearch.[regionId].aliyuncs.com";
        $client = new ImageSearch($config);
        $request = new DumpMetaRequest();
        // Required. The name of the Image Search instance. 
        $request->instanceName = "xxxxxx";
          
        try {
            $response = $client->dumpMeta($request);
            var_dump($response->body->toMap());
        } catch (TeaUnableRetryError $e) {
            var_dump($e->getLastException(), $e->getLastRequest());
          } catch (Exception $e) {
        }
    }
  • Sample responses
    array(3) {
      ["Data"]=>
      array(2) {
        ["DumpMetaStatus"]=>
        string(10) "PROCESSING"
        ["Id"]=>
        int(572)
      }
      ["RequestId"]=>
      string(36) "A1234E2C-C99E-122C-97D1-F30FE012533B"
      ["Success"]=>
      bool(true)
    }

DumpMetaList

  • Sample code
    function _dumpMetaList()
    {
        $config = new Config();
        $config->accessKeyId = "<accessKeyId>";
        $config->accessKeySecret = "<accessKeySecret>";
        $config->regionId = "<regionId>";
        $config->endpoint = "imagesearch.[regionId].aliyuncs.com";
        $client = new ImageSearch($config);
        $request = new DumpMetaListRequest();
        // Required. The name of the Image Search instance. 
        $request->instanceName = "xxxxxx";
        // Optional. The ID of the task that is used to export metadata. 
        $request->id = 567;
        // Optional. The ordinal number of the first entry that is returned. Default value: 1. 
        $request->pageNumber = 1;
        // Optional. The number of entries to be returned. Default value: 20. 
        $request->pageSize = 1;
          
        try {
            $response = $client->dumpMetaList($request);
            var_dump($response->body->toMap());
        } catch (TeaUnableRetryError $e) {
            var_dump($e->getLastException(), $e->getLastRequest());
          } catch (Exception $e) {
        }
    }
  • Sample responses
    array(2) {
      ["Data"]=>
      array(4) {
        ["DumpMetaList"]=>
        array(1) {
          [0]=>
          array(7) {
            ["Code"]=>
            string(1) "0"
            ["Id"]=>
            int(567)
            ["MetaUrl"]=>
            string(208) "https://xx/xx"
            ["Msg"]=>
            string(7) "success"
            ["Status"]=>
            string(7) "SUCCESS"
            ["UtcCreate"]=>
            int(1639969113000)
            ["UtcModified"]=>
            int(1639969140000)
          }
        }
        ["PageNumber"]=>
        int(1)
        ["PageSize"]=>
        int(1)
        ["TotalCount"]=>
        int(1)
      }
      ["RequestId"]=>
      string(36) "46044936-BA2E-10E2-9C82-C00FF83862E5"
    }

BatchTask

  • Sample code
    function _batchTask()
    {
        $config = new Config();
        $config->accessKeyId = "<accessKeyId>";
        $config->accessKeySecret = "<accessKeySecret>";
        $config->regionId = "<regionId>";
        $config->endpoint = "imagesearch.[regionId].aliyuncs.com";
        $client = new ImageSearch($config);
        $request = new IncreaseInstanceRequest();
        // Required. The name of the Image Search instance. 
        $request->instanceName = "xxxxxx";
        // Required. If images are stored in an Object Storage Service (OSS) bucket, enter the bucket name. 
        $request->bucketName = "xxxx";
        // Required. The path to the service where the images are stored. The path must start with a forward slash (/) and cannot end with a forward slash (/). 
        $request->path = "/public/xxx";
        // Optional. The callback address if the call succeeds. The address must start with the string http:// or https://. 
        $request->callbackAddress = "http://xxx/xxx";
          
        try {
            $response = $client->increaseInstance($request);
            var_dump($response->body->toMap());
        } catch (TeaUnableRetryError $e) {
            var_dump($e->getLastException(), $e->getLastRequest());
          } catch (Exception $e) {
        }
    }
  • Sample responses
    array(3) {
      ["Data"]=>
      array(2) {
        ["Id"]=>
        int(1475)
        ["IncrementStatus"]=>
        string(10) "PROCESSING"
      }
      ["RequestId"]=>
      string(36) "768C6C02-E3FE-1024-8461-103F7C529EFA"
      ["Success"]=>
      bool(true)
    }

BatchTaskList

  • Sample code
    function _batchTaskList()
    {
        $config = new Config();
        $config->accessKeyId = "<accessKeyId>";
        $config->accessKeySecret = "<accessKeySecret>";
        $config->regionId = "<regionId>";
        $config->endpoint = "imagesearch.[regionId].aliyuncs.com";
        $client = new ImageSearch($config);
        $request = new IncreaseListRequest();
        // Required. The name of the Image Search instance. 
        $request->instanceName = "xxxxxx";
        // Optional. The ID of the task. 
        $request->id = 567;
        // Optional. Query the name of the OSS bucket. 
        $request->bucketName = "xxxx";
        // Optional. Query the path to the OSS bucket. 
        $request->path = "/public/xxx";
        // Optional. The ordinal number of the first entry that is returned. Default value: 1. 
        $request->pageNumber = 1;
        // Optional. The number of entries to be returned. Default value: 20. 
        $request->pageSize = 1;
          
        try {
            $response = $client->increaseList($request);
            var_dump($response->body->toMap());
        } catch (TeaUnableRetryError $e) {
            var_dump($e->getLastException(), $e->getLastRequest());
          } catch (Exception $e) {
        }
    }
  • Sample responses
    array(2) {
      ["Data"]=>
      array(4) {
        ["Increments"]=>
        array(1) {
          ["Instance"]=>
          array(1) {
            [0]=>
            array(9) {
              ["BucketName"]=>
              string(21) "xxxxx"
              ["Code"]=>
              string(1) "0"
              ["ErrorUrl"]=>
              string(226) "https://xx/xx"
              ["Id"]=>
              int(1464)
              ["Msg"]=>
              string(7) "success"
              ["Path"]=>
              string(23) "/public/xxx"
              ["Status"]=>
              string(6) "NORMAL"
              ["UtcCreate"]=>
              int(1639107872000)
              ["UtcModified"]=>
              int(1639125540000)
            }
          }
        }
        ["PageNumber"]=>
        int(1)
        ["PageSize"]=>
        int(1)
        ["TotalCount"]=>
        int(1)
      }
      ["RequestId"]=>
      string(36) "603C696F-EC04-101F-8767-29A63382237A"
    }