15年软件开发经验,只做源码定制!

原创设计 定制开发

满足您的个性化需求

当前位置:首页 后端开发 Thinkphp5

airtable,上传数据篇,

教腾豪| 发布于 2021-09-23 22:37:22| 38阅读| 0点赞| 0评论
举报

通过airtable上的base,查看每个字段的值,传输数据

 public function xinzeng($id){
$order = Db::name('order')->where(['id'=>$id,'status'=>1])->find();
$data=[
'records'=>[
[
'fields'=>[
'ID'=>$order['id'],
'Member_id'=>$order['member_id'],
'Order Number'=>$order['order_num'],
'Order Date'=>date("Y-m-d",$success),
'Gross Premium'=>(float)$order['price'],
'Net Premium'=>(float)$order['cost_price'],
'Last Name'=>$order['xing'],
'First Name'=>$order['ming'],
'DOB'=>$order['age'],
'Gender'=>$order['sex'],
'Email'=>$order['email'],
'Citizenship'=>$order['country'],
'Grade'=>$order['grade'],
'Passport Number'=>$order['passport'],
'Phone Number'=>'+'.$phone_area.'-'.$order['phone'],
'Beneficiary First Name'=>$order['ben_name'],
'Beneficiary Last Name'=>$order['ben_xing'],
'Relation'=>$order['ben_rel'],
'Beneficiary DOB'=>$order['ben_age'],
'Beneficiary Email'=>$order['ben_email'],
'Address'=>$order['address'],
'State'=>$order['city_zhou'],
'City'=>$order['city_chengshi'],
'Zip Code'=>$order['zipcode'],
'Visa Type'=>$title,
'Plan'=>$ins['name'].'/'.$deduc,
'School'=>$school['title'],
'EffectiveFrom'=>$order['start_date'],
'Effective To'=>$order['end_date'],
'Coverage Days'=>(float)$order['date'],
'Status'=>$zhif,
'Channels'=>$order['liaojie'],
'Payment Methods'=>$fangshi,
'Credit Card or Admin Fee'=>(float)$order['sx_price'],
'Age'=>$nian,
]
]
]
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://api.airtable.com/v0/appnb67MsIVTKyMw6/%E8%AE%A2%E5%8D%95%E8%AF%A6%E6%83%85");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer keynFeBDTkWYkM116"
]);
//这两行是不检测ssl证书
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$result = curl_exec($ch);
curl_close($ch);
print_R(json_decode($result,true));
$res = json_decode($result,true);
$data = [
'order_id' =>$res['records'][0]['fields']['ID'],
'air_id'=>$res['records'][0]['id']
];
Db::name('air')->insert($data);
return '<success>ok</success>';
}

根据airtable上的字段名称,设置参数进行传递,名称必须对应



0

0条评论

别默默看啦~登录/注册一起参与讨论吧~

热门标签

教腾豪
微信扫一扫立即咨询
账号登录|扫码登录

立即注册 |忘记密码?

欢迎注册

已有账号马上登录

重置密码

扫码绑定微信
微信扫一扫

绑定手机号

分享到-微信

举报

  • 举报类型:

  • 举报描述:

您好,当前积分不足。

在线客服
拨打电话
17330196230 13230981129
顶部