金数据表单接口请求(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);
原文地址:https://www.cnblogs.com/hero-89/p/7771804.html