开发语言 | 资源下载 | 环境要求 |
---|---|---|
JAVA版资源 | SDK1.5 | 适用于Java语言、jdk版本1.5及以上的开发环境 |
.NET版资源 | SDK | 适用于Visual studio 2010及以上版本、Framework3.5及以上版本的开发环境 |
PHP版资源 | SDK | 适用于php5.5以上的开发环境 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | //实例化客户端 AlipayClient alipayClient = new DefaultAlipayClient( "https://openapi.alipay.com/gateway.do" , APP_ID, APP_PRIVATE_KEY, "json" , CHARSET, ALIPAY_PUBLIC_KEY, "RSA2" ); //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.open.public.template.message.industry.modify AlipayOpenPublicTemplateMessageIndustryModifyRequest request = new AlipayOpenPublicTemplateMessageIndustryModifyRequest(); //SDK已经封装掉了公共参数,这里只需要传入业务参数 //此次只是参数展示,未进行字符串转义,实际情况下请转义 request.setBizContent( " {" + " \"primary_industry_name\":\"IT科技/IT软件与服务\"," + " \"primary_industry_code\":\"10001/20102\"," + " \"secondary_industry_code\":\"10001/20102\"," + " \"secondary_industry_name\":\"IT科技/IT软件与服务\"" + " }" ); AlipayOpenPublicTemplateMessageIndustryModifyResponse response = alipayClient.execute(request); //调用成功,则处理业务逻辑 if (response.isSuccess()){ //..... } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | AlipayClient alipayClient = new DefaultAlipayClient( "https://openapi.alipay.com/gateway.do" , APP_ID, APP_PRIVATE_KEY, "json" , CHARSET, ALIPAY_PUBLIC_KEY, "RSA2" ); // 实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.offline.material.image.upload AlipayOfflineMaterialImageUploadRequest request = new AlipayOfflineMaterialImageUploadRequest(); request.setImageName( "test" ); //Windows请填写绝对路径,不支持相对路径;Linux支持相对路径 FileItem item = new FileItem( "C:/Downloads/ooopic_963991_7eea1f5426105f9e6069/16365_1271139700.jpg" ); request.setImageType( "JPG" ); request.setImageContent(item); //执行API请求 AlipayOfflineMaterialImageUploadResponse response = alipayClient.execute(request); //调用成功,则处理业务逻辑 if (response.isSuccess()){ //获取图片访问地址 String imageUrl = response.getImageUrl(); //..... } |
1 2 3 4 5 6 7 | AlipayClient alipayClient = new DefaultAlipayClient( "https://openapi.alipay.com/gateway.do" , APP_ID, APP_PRIVATE_KEY, "json" , CHARSET, ALIPAY_PUBLIC_KEY, "RSA2" ); //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.user.userinfo.share AlipayUserUserinfoShareRequest request = new AlipayUserUserinfoShareRequest(); //授权类接口执行API调用时需要带上accessToken AlipayUserUserinfoShareResponse response= alipayClient.execute(request, "accessToken" ); //业务处理 //... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | AlipayClient alipayClient = new DefaultAlipayClient( "https://openapi.alipay.com/gateway.do" , APP_ID, APP_PRIVATE_KEY, "json" , CHARSET, ALIPAY_PUBLIC_KEY, "RSA2" ); //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.open.public.template.message.industry.modify AlipayOpenPublicTemplateMessageIndustryModifyRequest request = new AlipayOpenPublicTemplateMessageIndustryModifyRequest(); //SDK已经封装掉了公共参数,这里只需要传入业务参数 //此次只是参数展示,未进行字符串转义,实际情况下请转义 request.setBizContent( " { " + " \"primary_industry_name\":\"IT科技/IT软件与服务\"," + " \"primary_industry_code\":\"10001/20102\"," + " \"secondary_industry_code\":\"10001/20102\"," + " \"secondary_industry_name\":\"IT科技/IT软件与服务\"" + " }" ); //ISV代理商户调用需要传入app_auth_token request.putOtherTextParam( "app_auth_token" , "201511BBaaa6464f271f49e482f2e9fe63ca5F05" ); AlipayOpenPublicTemplateMessageIndustryModifyResponse response = alipayClient.execute(request); //调用成功,则处理业务逻辑 if (response.isSuccess()){ //..... } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | IAopClient client = new DefaultAopClient( "https://openapi.alipay.com/gateway.do" , APPID, APP_PRIVATE_KEY, "json" , "1.0" , "RSA2" , ALIPAY_PUBLIC_KEY, CHARSET, false ); //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称如:alipay.open.public.template.message.industry.modify AlipayOpenPublicTemplateMessageIndustryModifyRequest request = new AlipayOpenPublicTemplateMessageIndustryModifyRequest(); //SDK已经封装掉了公共参数,这里只需要传入业务参数 //此次只是参数展示,未进行字符串转义,实际情况下请转义 request.BizContent= "{" + " \"primary_industry_name\":\"IT科技/IT软件与服务\"," + " \"primary_industry_code\":\"10001/20102\"," + " \"secondary_industry_code\":\"10001/20102\"," + " \"secondary_industry_name\":\"IT科技/IT软件与服务\"" + " }" ; AlipayOpenPublicTemplateMessageIndustryModifyResponse response = client.execute(request); //调用成功,则处理业务逻辑 if (response.isSuccess()){ //..... } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | IAopClient client = new DefaultAopClient( "https://openapi.alipay.com/gateway.do" , APPID, APP_PRIVATE_KEY, "json" , "1.0" , "RSA2" , ALIPAY_PUBLIC_KEY, CHARSET, false ); // 实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.offline.material.image.upload AlipayOfflineMaterialImageUploadRequest request = new AlipayOfflineMaterialImageUploadRequest(); request.setImageName( "test" ); //Windows请填写绝对路径,不支持相对路径;Linux支持相对路径 FileItem item = new FileItem( "C:/Downloads/ooopic_963991_7eea1f5426105f9e6069/16365_1271139700.jpg" ); request.setImageType( "JPG" ); request.setImageContent(item); //执行API请求 AlipayOfflineMaterialImageUploadResponse response = alipayClient.execute(request); //调用成功,则处理业务逻辑 if (response.isSuccess()){ //获取图片访问地址 String imageUrl = response.getImageUrl(); //..... } |
1 2 3 4 5 6 7 | IAopClient client = new DefaultAopClient( "https://openapi.alipay.com/gateway.do" , APPID, APP_PRIVATE_KEY, "json" , "1.0" , "RSA2" , ALIPAY_PUBLIC_KEY, CHARSET, false ); //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.user.userinfo.share AlipayUserUserinfoShareRequest request = new AlipayUserUserinfoShareRequest(); //授权类接口执行API调用时需要带上accessToken AlipayUserUserinfoShareResponse response= client.execute(req, "accessToken" ); //业务处理 //... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | IAopClient client = new DefaultAopClient( "https://openapi.alipay.com/gateway.do" , APPID, APP_PRIVATE_KEY, "json" , "1.0" , "RSA2" , ALIPAY_PUBLIC_KEY, CHARSET, false ); //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.open.public.template.message.industry.modify AlipayOpenPublicTemplateMessageIndustryModifyRequest request = new AlipayOpenPublicTemplateMessageIndustryModifyRequest(); //SDK已经封装掉了公共参数,这里只需要传入业务参数 //此次只是参数展示,未进行字符串转义,实际情况下请转义 request.setBizContent( " {" + " \"primary_industry_name\":\"IT科技/IT软件与服务\"," + " \"primary_industry_code\":\"10001/20102\"," + " \"secondary_industry_code\":\"10001/20102\"," + " \"secondary_industry_name\":\"IT科技/IT软件与服务\"" + " }" ); AlipayOpenPublicTemplateMessageIndustryModifyResponse response = client.execute(request, null , "app_auth_token" ); //调用成功,则处理业务逻辑 if (response.isSuccess()){ //..... } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | $c = new AopClient; $c->appId = "app_id" ; $c->rsaPrivateKey = '请填写开发者私钥去头去尾去回车,一行字符串' ; $c->format = "json" ; $c->charset= "GBK" ; $c->signType= "RSA2" ; $c->alipayrsaPublicKey = '请填写支付宝公钥,一行字符串' ; //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.open.public.template.message.industry.modify $request = new AlipayOpenPublicTemplateMessageIndustryModifyRequest(); //SDK已经封装掉了公共参数,这里只需要传入业务参数 //此次只是参数展示,未进行字符串转义,实际情况下请转义 $request->bizContent = "{" + " \"primary_industry_name\":\"IT科技/IT软件与服务\"," + " \"primary_industry_code\":\"10001/20102\"," + " \"secondary_industry_code\":\"10001/20102\"," + " \"secondary_industry_name\":\"IT科技/IT软件与服务\"" + " }" ; $response= $c->execute($request); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | $c = new AopClient; $c->appId = "app_id" ; $c->rsaPrivateKey = '请填写开发者私钥去头去尾去回车,一行字符串' ; $c->format = "json" ; $c->charset = "GBK" ; $c->signType= "RSA2" ; $c->alipayrsaPublicKey = '请填写支付宝公钥,一行字符串' ; //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.offline.material.image.upload $request = new AlipayOfflineMaterialImageUploadRequest(); $request->setImageName( "测试文件" ); $request->setImageType( "jpg" ); //Windows请填写绝对路径,不支持相对路径;Linux支持相对路径 $request->setImageContent( "@" . "本地文件路径" ); $response = $c->execute($request); //获取图片地址 $response->getImageUrl(); |
1 2 3 4 5 6 7 8 9 10 11 12 | $c = new AopClient; $c->appId = "app_id" ; $c->rsaPrivateKey = '请填写开发者私钥去头去尾去回车,一行字符串' ; $c->format = "json" ; $c->charset = "GBK" ; $c->signType= "RSA2" ; $c->alipayrsaPublicKey = '请填写支付宝公钥,一行字符串' ; //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.user.userinfo.share $request= new AlipayUserUserinfoShareRequest(); //授权类接口执行API调用时需要带上accessToken $response= $c->execute($request, "accessToken" ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | $c = new AopClient; $c->appId = "app_id" ; $c->rsaPrivateKey = '请填写开发者私钥去头去尾去回车,一行字符串' ; $c->format = "json" ; $c->charset = "GBK" ; $c->signType= "RSA2" ; $c->alipayrsaPublicKey = '请填写支付宝公钥,一行字符串' ; ##实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.open. public .template.message.industry.modify $request = new AlipayOpenPublicTemplateMessageIndustryModifyRequest(); //SDK已经封装掉了公共参数,这里只需要传入业务参数 //此次只是参数展示,未进行字符串转义,实际情况下请转义 $request->bizContent = "{" + " \"primary_industry_name\":\"IT科技/IT软件与服务\"," + " \"primary_industry_code\":\"10001/20102\"," + " \"secondary_industry_code\":\"10001/20102\"," + " \"secondary_industry_name\":\"IT科技/IT软件与服务\"" + " }" ; //ISV代理商户调用需要传入app_auth_token $response= $c->execute($request,NULL, "app_auth_token" ); |
1 2 3 4 5 6 7 | /** @param content 待签名字符串 @param privateKey 加签私钥 @param charset 加签字符集 @param sign_type 签名方式 **/ String AlipaySignature.rsaSign(String content, String privateKey, String charset, String sign_type) |
验签方法,根据接口不同,验签时会去掉sign_type(rsaCheckV1)或者保留sign_type(rsaCheckV2)。
1 2 3 4 5 6 7 8 9 10 11 12 13 | /** 此方法会去掉sign_type做验签,暂时除生活号(原服务窗)激活开发者模式外都使用V1。 @param params 参数列表(包括待验签参数和签名值sign) key-参数名称 value-参数值 @param publicKey 验签公钥 @param charset 验签字符集 **/ boolean AlipaySignature.rsaCheckV1(Map<String, String> params, String publicKey, String charset, String sign_type) /** 此方法不会去掉sign_type验签,用于生活号(原服务窗)激活开发者模式 @param params 参数列表(包括待验签参数和签名值sign) key-参数名称 value-参数值 @param publicKey 验签公钥 @param charset 验签字符集 **/ boolean AlipaySignature.rsaCheckV2(Map<String, String> params, String publicKey, String charset, String sign_type) |