PHP code example of i25ma / vip-union

1. Go to this page and download the library: Download i25ma/vip-union library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

i25ma / vip-union example snippets




$ctx = null;
try {
	//1、获取服务客户端
	$service = \vipapis\address\AddressServiceClient::getService();
	
	//2、设置系统级调用参数,只需在程序开始调用前设置一次即可
	$ctx = \Osp\Context\InvocationContextFactory::getInstance ();
	$ctx->setAppKey("appKey");//替换为你的appKey
	$ctx->setAppSecret("appSecret");//替换为你的appSecret
	//$ctx->setAccessToken("accessToken");//替换为你的accessToken,通过Oauth认证时必填
	$ctx->setAppURL("http://sandbox.vipapis.com/");//沙箱环境
	//$ctx->setAppURL("https://vop.vipapis.com/");//正式环境
	//$ctx->setTimeOut(30)//超时时间,可选,默认30秒
	
	//3、调用API及返回
	$rtn = $service->getProvinceWarehouse(\vipapis\address\Is_Show_GAT::SHOW_ALL);
	var_dump($rtn);
} catch (\Osp\Exception\OspException $e) {
	//4、捕获异常
	var_dump($ctx->getSign());//获取最近一次调用的sign值