serverUrl,
$this -> appId,
$this -> partner_private_key,
$this -> format,
$this -> charset
);
$response = null;
$outputStream = null;
$request = $alipayClient -> getContents() ;
//200
//echo( '状态码:'. $request -> getCode() .', ');
//echo '
';
$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 '
';
//echo '参数:';
//echo ($request -> getParams());
//echo '
' ;
}
}
// 测试
$test1 = new TestImage();
$test1 -> load();