当前位置:Gxlcms > PHP教程 > 银行卡实名认证接口调用代码PHP实例

银行卡实名认证接口调用代码PHP实例

时间:2021-07-01 10:21:17 帮助过:46人阅读

  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | JuhePHP [ NO ZUO NO DIE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2010-2015 http://juhe.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: Juhedata <info@juhe.cn>
  8. // +----------------------------------------------------------------------
  9. //----------------------------------
  10. // 银行卡实名认证调用示例代码 - 聚合数据
  11. // 在线接口文档:https://www.juhe.cn/docs/api/id/188
  12. //----------------------------------
  13. header('Content-type:text/html;charset=utf-8');
  14. //配置您申请的appkey
  15. $appkey = "*********************";
  16. //************1.银行卡实名认证查询************
  17. $url = "http://v.juhe.cn/verifybankcard/query";
  18. $params = array(
  19. "bankcard" => "",//银行卡卡号
  20. "realname" => "",//姓名(需utf8编码的urlencode)
  21. "key" => $appkey,//应用APPKEY(应用详细页查询)
  22. );
  23. $paramstring = http_build_query($params);
  24. $content = juhecurl($url,$paramstring);
  25. $result = json_decode($content,true);
  26. if($result){
  27. if($result['error_code']=='0'){
  28. print_r($result);
  29. }else{
  30. echo $result['error_code'].":".$result['reason'];
  31. }
  32. }else{
  33. echo "请求失败";
  34. }
  35. //**************************************************
  36. /**
  37. * 请求接口返回内容
  38. * @param string $url [请求的URL地址]
  39. * @param string $params [请求的参数]
  40. * @param int $ipost [是否采用POST形式]
  41. * @return string
  42. */
  43. function juhecurl($url,$params=false,$ispost=0){
  44. $httpInfo = array();
  45. $ch = curl_init();
  46. curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
  47. curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData' );
  48. curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );
  49. curl_setopt( $ch, CURLOPT_TIMEOUT , 60);
  50. curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
  51. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  52. if( $ispost )
  53. {
  54. curl_setopt( $ch , CURLOPT_POST , true );
  55. curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
  56. curl_setopt( $ch , CURLOPT_URL , $url );
  57. }
  58. else
  59. {
  60. if($params){
  61. curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
  62. }else{
  63. curl_setopt( $ch , CURLOPT_URL , $url);
  64. }
  65. }
  66. $response = curl_exec( $ch );
  67. if ($response === FALSE) {
  68. //echo "cURL Error: " . curl_error($ch);
  69. return false;
  70. }
  71. $httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );
  72. $httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) );
  73. curl_close( $ch );
  74. return $response;
  75. }

人气教程排行