No Description

TestImage.php 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * Alipay.com Inc.
  4. * Copyright (c) 2004-2014 All Rights Reserved.
  5. */
  6. include('../AlipayMobilePublicMultiMediaClient.php');
  7. header("Content-type: text/html; charset=gbk");
  8. /**
  9. *
  10. * @author wangYuanWai
  11. * @version $Id: Test.hp, v 0.1 Aug 6, 2014 4:20:17 PM yikai.hu Exp $
  12. */
  13. class TestImage{
  14. public $partner_public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCitD16CypwZILTpdJL8nPV9rVFHYf5UWa/URNX6469mbQLpWfjKM/VSWRXsNVGSM3itOO/KG2Pw4x5g9xjH6iaE4LlaidjBIPpifISSlnpbyi4HxQTZYgMPv/TuiWofUN5kcwg/KQAQxB2OwTOeFu2i3LhqSCDmv6koTvHW15/hQIDAQAB";
  15. public $alipay_public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIgHnOn7LLILlKETd6BFRJ0GqgS2Y3mn1wMQmyh9zEyWlz5p1zrahRahbXAfCfSqshSNfqOmAQzSHRVjCqjsAw1jyqrXaPdKBmr90DIpIxmIyKXv4GGAkPyJ/6FTFY99uhpiq0qadD/uSzQsefWo0aTvP/65zi3eof7TcZ32oWpwIDAQAB";
  16. //公用变量
  17. 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";
  18. public $appId = "2013121100055554";
  19. 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=';
  20. public $format = "json";
  21. public $charset = "GBK";
  22. function __construct(){
  23. }
  24. public function load() {
  25. $alipayClient = new AlipayMobilePublicMultiMediaClient(
  26. $this -> serverUrl,
  27. $this -> appId,
  28. $this -> partner_private_key,
  29. $this -> format,
  30. $this -> charset
  31. );
  32. $response = null;
  33. $outputStream = null;
  34. $request = $alipayClient -> getContents() ;
  35. //200
  36. //echo( '状态码:'. $request -> getCode() .', ');
  37. //echo '<hr /><br /><br /><br />';
  38. $fileType = $request -> getType();
  39. //echo( '类型:'. $fileType .', ');
  40. if( $fileType == 'text/plain'){
  41. //出错,返回 json
  42. echo $request -> getBody();
  43. }else{
  44. $type = $request -> getFileSuffix( $fileType );
  45. //echo $this -> getParams();
  46. //exit();
  47. //返回 文件流
  48. header("Content-type: ". $fileType ); //类型
  49. header("Accept-Ranges: bytes");//告诉客户端浏览器返回的文件大小是按照字节进行计算的
  50. header("Accept-Length: ". $request -> getContentLength() );//文件大小
  51. header("Content-Length: ". $request -> getContentLength() );//文件大小
  52. header('Content-Disposition: attachment; filename="'. time() .'.'. $type .'"'); //文件名
  53. echo $request -> getBody() ;
  54. exit ( ) ;
  55. }
  56. //echo( '内容: , '. $request -> getContentLength() );
  57. //echo '<hr /><br /><br /><br />';
  58. //echo '参数:<pre>';
  59. //echo ($request -> getParams());
  60. //echo '</pre>' ;
  61. }
  62. }
  63. // 测试
  64. $test1 = new TestImage();
  65. $test1 -> load();