金數據表單接口請求(php)

金數據是一個在線表單製做工具,功能十分強大,同時爲開發者提供了金數據開發平臺php

現根據本身的開發經歷分享下php語言請求金數據接口方法html

開發平臺提供如下兩個主要接口 (其中APIKEYAPISECRET從我的中心獲取),接口都是基於HTTP BASIC驗證json

1、獲取某表單接口(已知某表單id根據id獲取其包含的字段)api

參考代碼以下:app

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

2、填寫某表單(已知某表單id和字段列表)工具

參考代碼以下:ui

$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);
相關文章
相關標籤/搜索