金数据表单接口请求(php)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了金数据表单接口请求(php)相关的知识,希望对你有一定的参考价值。

金数据是一个在线表单制作工具,功能十分强大,同时为开发者提供了金数据开发平台

现根据自己的开发经历分享下php语言请求金数据接口方法

开发平台提供以下两个主要接口 (其中APIKEYAPISECRET从个人中心获取),接口都是基于HTTP BASIC验证

一、获取某表单接口(已知某表单id根据id获取其包含的字段)

参考代码如下:

$url = ‘https://APIKEY:APISECRET@jinshuju.net/api/v1/forms/‘.FORMID;
$res = file_get_contents($url);
return json_decode($res,true);            

二、填写某表单(已知某表单id和字段列表)

参考代码如下:

$url = ‘https://APIKEY:APISECRET@jinshuju.net/api/v1/forms/‘.FORMID;
$data = array(
      ‘field_1‘ => ‘XXX‘,
      ‘field_4‘ => ‘XXX‘,
);
$query = http_build_query($data);
$options[‘http‘] = array(
       ‘timeout‘=>30,
       ‘method‘ => ‘POST‘,
       ‘header‘ => ‘Content-type:application/x-www-form-urlencoded‘,
       ‘content‘ => $query
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return json_decode($result,true);

 

以上是关于金数据表单接口请求(php)的主要内容,如果未能解决你的问题,请参考以下文章