【发布时间】:2019-09-11 07:11:44
【问题描述】:
我正在使用重力表单和 wordpress 将 Verticalresponse 订阅表单与 curl 集成以使用不记名令牌进行授权但无法建立连接
function post_to_vr($entry, $form ) {
$raw_data = [
'email' => $entry
];
$authorization = "Authorization: Bearer x7ab8errzuj87u24qemzytu3";
$ch = curl_init('https://vrapi.verticalresponse.com/api/v1/lists/36283883717887/contacts');
$data = json_encode($raw_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $authorization ));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result);
}
add_action("gform_after_submission", "post_to_vr",10, 2);
【问题讨论】:
标签: gravity-forms-plugin wordpress-rest-api