This topic provides code examples on how to initialize the SDK for C/C++ by using your AccessKey pair and Security Token Service (STS) token.

Prerequisites

Initialize the SDK

Determine the region where you want to call ApsaraVideo VOD operations. For more information about the supported regions, see Access regions and IDs. For example, if you want to call the operations in the China (Shanghai) region, use cn-shanghai.
  1. Use the AccessKey pair to initialize the SDK. Example:
    #include "vod_sdk/openApiUtil.h"
    
    VodCredential initVodClient(std::string accessKeyId, std::string accessKeySecret) {
        VodCredential authInfo;
        authInfo.accessKeyId = accessKeyId;
        authInfo.accessKeySecret = accessKeySecret;
        authInfo.regionId = "cn-shanghai";
        return authInfo;
    }
  2. Use an STS token to initialize the SDK. Example:
    #include "vod_sdk/openApiUtil.h"
    
    VodCredential initVodClient(std::string accessKeyId, std::string accessKeySecret, std::String securityToken) {
        VodCredential authInfo;
        authInfo.accessKeyId = accessKeyId;
        authInfo.accessKeySecret = accessKeySecret;
        authInfo.securityToken = securityToken;
        authInfo.regionId = "cn-shanghai";
        return authInfo;
    }

FAQ

  • The dynamic link library (DLL) is not installed in the directory where the DLL is complied or the directory where the DLL is run. What do I do?
    Perform the following operations. Example:
    Add the directory where the DLL is installed to the /etc/ld.so.conf file.
    Run the ldconfig command.        
    You must add the following parameters when you compile the DLL:
    lcurl
    ljsoncpp
    lvod_sdk
    loss_c_sdk
    lapr-1
    laprutil-1
    lmxml
  • Which input parameters does the getAcsResponse function support?
    The getAcsResponse function is a request function. The following parameters are supported:
    • vodCredential: For more information, see Initialize the SDK.
    • apiName: The name of the API operation.
    • args: The parameters.
  • Which function returns a value of the VodApiResponse type?
    The getAcsResponse function returns the value of the VodApiResponse type.
    • If the request succeeds, the value of httpCode in VodApiResponse is an HTTP status code and the value of result is in the JSON format. You can configure the args parameter to specify the data types of return results.
    • If the request fails, the value of httpCode in VodApiResponse is -1 and the value of result is an error message.