api-with-response-encode.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * 通用接口调用 -> 查询交易
  4. */
  5. require_once '../../vendor/autoload.php';
  6. use Lakala\OpenAPISDK\v3\Configuration;
  7. $config = new \Lakala\OpenAPISDK\V3\Configuration();
  8. $api = new \Lakala\OpenAPISDK\V3\Api\LakalaApi($config, \Lakala\OpenAPISDK\V3\Api\EncryptMode::RESPONSE);
  9. try {
  10. // 字符串格式的body
  11. $body = '{"timestamp": 1655452194480,"ver": "1.0.0","reqId": "bf167a53f4a34716b66e26a9a5d803a6","reqData": {"bmcpNo": "1","mercId": "8221000581200BS"}}';
  12. // json格式body
  13. $json = new stdClass;
  14. $json->timestamp = "1655452194480";
  15. $json->ver = "1.0.0";
  16. $json->reqId = "bf167a53f4a34716b66e26a9a5d803a6";
  17. $json->reqData = new stdClass;
  18. $json->reqData->bmcpNo = "1";
  19. $json->reqData->mercId = "8221000581200BS";
  20. $response = $api->apiWithBody('/api/v2/laep/industry/bankcard/list', $json);
  21. print_r($response->getRespData());
  22. echo $response->getCode();
  23. # 响应头信息
  24. print_r($response->getHeaders());
  25. # 响应原文
  26. echo $response->getOriginalText();
  27. } catch (\Lakala\OpenAPISDK\V3\ApiException $e) {
  28. echo $e->getMessage();
  29. }