分享艾科智泊一点停平台的接口

工作中用到了一点停开放平台的接口,由于他们平台没有php版本的demo,所以写了一个php的类,分享给大家,如果有需要的小伙伴可以尝试一下。

class.ydt.php

<?php
// +----------------------------------------------------------------------
// | YDT(一点停接口授权类)
// +----------------------------------------------------------------------
// | Copyright (c) 2010-2015 http://juhe.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: white <liuhao@tahan.com.cn-->
// +----------------------------------------------------------------------
 
//----------------------------------
// 一点停接口授权类
//----------------------------------
class yidianting{
    
    public $appkey="appkey";  //填上自己找一点停工作人员获取的信息
    
    private $apppass="apppass";    //填上自己找一点停工作人员获取的信息
    
    private $baseurl="https://openapi-test.yidianting.xin/openydt/api/v2/";
    
    
    
    
    //获取数据接口
    public function getData($interface,$arr,$time){
        $str1=$this->appkey.':'.$time.':'.$this->apppass;
        $sign=md5($str1);//md5加密获取sign值
        $str2=$this->appkey.':'.$time;
        $auth=base64_encode($str2);//base64获取authrization值
        $url=$this->baseurl.$interface.'?sign='.$sign;
        
        $body=json_encode($arr);
        $headers=array(
                    'Accept:application/json',
                    'Content-Type:application/json;charset=utf-8',
                    
                    'Authorization:'.$auth,
                );
        return $this->ydtcurl($url,$headers,$body);
        
    }


    //一点停curl接口
    public function ydtcurl($url, $headers, $body="", $isPost=true, $isImage=false ) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        
    curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
    
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

那么具体如何调用呢?

写了几个示范的例子:

比如要调用模拟进出场接口,先看官方文档,

具体实现方法如下代码

<?php

// header('Content-type:text/html;charset=utf-8');
include "class.ydt.php"; //引入一点停请求类

$ydt=new yidianting();
$interface='mockInOut';
$time=date('YmdHis',time());
$arr= array("parkCode"=>"2KPI5T73","carNo"=>"粤Y12345","mockType"=>"0","operator"=>"operator","operateTime"=>"2018-08-06 09:00:00");

$result=$ydt->getData($interface,$arr,$time);
echo "<pre>";
print_r (json_decode($result));
echo "</pre>";

 系统返回如下:

再举一个接口实例调用如下:

接口文档如下:

实现接口如下: 

<?php

// header('Content-type:text/html;charset=utf-8');
include "class.ydt.php"; //引入一点停请求类

$ydt=new yidianting();
$interface='mockInOut';
$time=date('YmdHis',time());

$interface='getCarOwnerInfo';
$arr= array("parkCode"=>"2KPI5T73","pageNumber"=>"1","pageSize"=>"1");

$result=$ydt->getData($interface,$arr,$time);

echo "<pre>";
print_r (json_decode($result));
echo "</pre>";

系统返回如下:

艾科智泊公司的一点停开放平台的接口文档地址,请参考。

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wuhanwhite

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值