【问题标题】:How to authorise verticalresponse with Bearer token using curl in wordpress gravity form如何使用 wordpress 重力形式的 curl 使用 Bearer 令牌授权垂直响应
【发布时间】: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


    【解决方案1】:

    它看起来还不错,除了一件事,即

    替换:

    $raw_data = [
        'email' => $entry
    ];
    

    与:

    $raw_data = [
        'email' => $entry[x]
    ];
    

    其中“x”将是保存电子邮件数据的数组的索引值。

    希望这会有所帮助。编码愉快。

    【讨论】:

      猜你喜欢
      • 2018-08-21
      • 1970-01-01
      • 2022-11-17
      • 2021-04-15
      • 2019-11-26
      • 2013-01-12
      • 2013-04-08
      • 1970-01-01
      • 2015-08-06
      相关资源
      最近更新 更多