V2SupplementaryPictureRequestDemo.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * 图片上传 - 示例
  4. *
  5. * @author sdk-generator
  6. * @Description
  7. */
  8. namespace BsPayDemo;
  9. // 1. 资源及配置加载
  10. require_once dirname(__FILE__) . "/loader.php";
  11. require_once dirname(__FILE__). "/../BsPaySdk/request/V2SupplementaryPictureRequest.php";
  12. use BsPaySdk\core\BsPayClient;
  13. use BsPaySdk\request\V2SupplementaryPictureRequest;
  14. use CURLFile;
  15. // 2.组装请求参数
  16. $request = new V2SupplementaryPictureRequest();
  17. // 业务请求流水号
  18. $request->setReqSeqId(date("YmdHis").mt_rand());
  19. // 业务请求日期
  20. $request->setReqDate(date("Ymd"));
  21. // 图片类型
  22. $request->setFileType("F01");
  23. // 设置非必填字段
  24. $extendInfoMap = getExtendInfos();
  25. $request->setExtendInfo($extendInfoMap);
  26. // 3. 发起API调用
  27. $client = new BsPayClient();
  28. $result = $client->postRequest($request,new CURLFile(dirname(__FILE__)."/api_logo.png","image/png","api_logo.png"));
  29. if (!$result || $result->isError()) { //失败处理
  30. var_dump($result -> getErrorInfo());
  31. } else { //成功处理
  32. var_dump($result);
  33. }
  34. /**
  35. * 非必填字段
  36. *
  37. */
  38. function getExtendInfos() {
  39. // 设置非必填字段
  40. $extendInfoMap = array();
  41. // 商户号
  42. $extendInfoMap["huifu_id"]= "6666000103413615";
  43. return $extendInfoMap;
  44. }