TestImage.php
3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* Alipay.com Inc.
* Copyright (c) 2004-2014 All Rights Reserved.
*/
include('../AlipayMobilePublicMultiMediaClient.php');
header("Content-type: text/html; charset=gbk");
/**
*
* @author wangYuanWai
* @version $Id: Test.hp, v 0.1 Aug 6, 2014 4:20:17 PM yikai.hu Exp $
*/
class TestImage{
public $partner_public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCitD16CypwZILTpdJL8nPV9rVFHYf5UWa/URNX6469mbQLpWfjKM/VSWRXsNVGSM3itOO/KG2Pw4x5g9xjH6iaE4LlaidjBIPpifISSlnpbyi4HxQTZYgMPv/TuiWofUN5kcwg/KQAQxB2OwTOeFu2i3LhqSCDmv6koTvHW15/hQIDAQAB";
public $alipay_public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIgHnOn7LLILlKETd6BFRJ0GqgS2Y3mn1wMQmyh9zEyWlz5p1zrahRahbXAfCfSqshSNfqOmAQzSHRVjCqjsAw1jyqrXaPdKBmr90DIpIxmIyKXv4GGAkPyJ/6FTFY99uhpiq0qadD/uSzQsefWo0aTvP/65zi3eof7TcZ32oWpwIDAQAB";
//公用变量
public $serverUrl = 'http://publicexprod.d5336aqcn.alipay.net/chat/multimedia.do';//'http://publicexprod.d5336aqcn.alipay.net/chat/multimedia.do';//'http://i.com/works/photo-sdk/_data/1.jpg';//"http://i.com/works/photo-sdk/_data/publicexprod.php";//"http://publicexprod.d5336aqcn.alipay.net/chat/multimedia.do";
public $appId = "2013121100055554";
public $partner_private_key = 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKK0PXoLKnBkgtOl0kvyc9X2tUUdh/lRZr9RE1frjr2ZtAulZ+Moz9VJZFew1UZIzeK0478obY/DjHmD3GMfqJoTguVqJ2MEg+mJ8hJKWelvKLgfFBNliAw+/9O6Jah9Q3mRzCD8pABDEHY7BM54W7aLcuGpIIOa/qShO8dbXn+FAgMBAAECgYA8+nQ380taiDEIBZPFZv7G6AmT97doV3u8pDQttVjv8lUqMDm5RyhtdW4n91xXVR3ko4rfr9UwFkflmufUNp9HU9bHIVQS+HWLsPv9GypdTSNNp+nDn4JExUtAakJxZmGhCu/WjHIUzCoBCn6viernVC2L37NL1N4zrR73lSCk2QJBAPb/UOmtSx+PnA/mimqnFMMP3SX6cQmnynz9+63JlLjXD8rowRD2Z03U41Qfy+RED3yANZXCrE1V6vghYVmASYsCQQCoomZpeNxAKuUJZp+VaWi4WQeMW1KCK3aljaKLMZ57yb5Bsu+P3odyBk1AvYIPvdajAJiiikRdIDmi58dqfN0vAkEAjFX8LwjbCg+aaB5gvsA3t6ynxhBJcWb4UZQtD0zdRzhKLMuaBn05rKssjnuSaRuSgPaHe5OkOjx6yIiOuz98iQJAXIDpSMYhm5lsFiITPDScWzOLLnUR55HL/biaB1zqoODj2so7G2JoTiYiznamF9h9GuFC2TablbINq80U2NcxxQJBAMhw06Ha/U7qTjtAmr2qAuWSWvHU4ANu2h0RxYlKTpmWgO0f47jCOQhdC3T/RK7f38c7q8uPyi35eZ7S1e/PznY=';
public $format = "json";
public $charset = "GBK";
function __construct(){
}
public function load() {
$alipayClient = new AlipayMobilePublicMultiMediaClient(
$this -> serverUrl,
$this -> appId,
$this -> partner_private_key,
$this -> format,
$this -> charset
);
$response = null;
$outputStream = null;
$request = $alipayClient -> getContents() ;
//200
//echo( '状态码:'. $request -> getCode() .', ');
//echo '<hr /><br /><br /><br />';
$fileType = $request -> getType();
//echo( '类型:'. $fileType .', ');
if( $fileType == 'text/plain'){
//出错,返回 json
echo $request -> getBody();
}else{
$type = $request -> getFileSuffix( $fileType );
//echo $this -> getParams();
//exit();
//返回 文件流
header("Content-type: ". $fileType ); //类型
header("Accept-Ranges: bytes");//告诉客户端浏览器返回的文件大小是按照字节进行计算的
header("Accept-Length: ". $request -> getContentLength() );//文件大小
header("Content-Length: ". $request -> getContentLength() );//文件大小
header('Content-Disposition: attachment; filename="'. time() .'.'. $type .'"'); //文件名
echo $request -> getBody() ;
exit ( ) ;
}
//echo( '内容: , '. $request -> getContentLength() );
//echo '<hr /><br /><br /><br />';
//echo '参数:<pre>';
//echo ($request -> getParams());
//echo '</pre>' ;
}
}
// 测试
$test1 = new TestImage();
$test1 -> load();