【问题标题】:GetResponse API contact creation with custom filed php使用自定义字段 php 创建 GetResponse API 联系人
【发布时间】:2018-05-17 21:38:05
【问题描述】:

我正在尝试使用 GetResponse API 使用自定义字段创建新联系人,这是我的代码:

$headers = [
                    'Accept: application/json',
                    'Content-Type: application/json',
                    'X-Auth-Token: api-key '.$model->getresponse_key
                ];

                $curl = curl_init();
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($curl, CURLOPT_URL, 'https://api.getresponse.com/v3/contacts');
                curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
                curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode([ 'name' => $user->full_name, 'email' => $user->email, 'campaign' => [ 'campaignId' => $model->getresponse_campaign ] , 'customFieldValues' => [['customFieldId' => 'tel', 'value' => [$user->phone]]]], JSON_FORCE_OBJECT));
                curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
                curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
                $result = curl_exec($curl);
                $result2 = json_decode($result);

我收到了这样的回复:

object(stdClass)#174 (7) {
      ["httpStatus"]=>
      int(400)
      ["code"]=>
      int(1000)
      ["codeDescription"]=>
      string(78) "General error of validation process, more details should be in context section"
      ["message"]=>
      string(34) "Custom field by id: tel not found "
      ["moreInfo"]=>
      string(49) "https://apidocs.getresponse.com/en/v3/errors/1000"
      ["context"]=>
      array(0) {
      }
      ["uuid"]=>
      string(36) "b5a2465b-08df-4cdd-80c8-**********"
    }

我真的不知道该代码可能出了什么问题,请帮忙。

【问题讨论】:

  • 根据响应“ID 的自定义字段:未找到电话”,可能是拼写错误?叫电话吗?
  • 我自己将“tel”作为自定义字段

标签: php getresponse


【解决方案1】:
You can use this - 

$response = new GetResponse($access_token);
$campaign = array('campaignId'=>123);
$params = array(
    'email' => $email,
    'campaign' => $campaign,
    'name' => $fname.' '.$lname,
);
$result = $response->**addContact**($params);
$status = $response->http_status;
print_r($status);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-19
    • 2020-06-13
    相关资源
    最近更新 更多