【发布时间】:2019-01-26 14:54:21
【问题描述】:
我的任务是在这个 api 上进行身份验证 https://api.getresponse.com/v3/accounts
然后需要保存在下面的api上 https://api.getresponse.com/v3/POST/contacts
数据必须采用以下格式
{
"name": "Hemant Maurya",
"email": "xyz@yahoo.com",
"dayOfCycle": "0",
"campaign": {
"campaignId": "6mzZL"
},
"tags": [
{
"tagId": "Xw"
},
{
"tagId": "Nn"
}
],
"scoring": 25,
"customFieldValues": [
{
"customFieldId": "n",
"value": [
"white"
]
}
],
"ipAddress": "14.143.38.111"
}
以下代码可以验证
$url = "https://api.getresponse.com/v3/accounts";
$headers = array();
$headers[] = "X-Auth-Token: api-key 17fbe43cc8a23daaf36b35093c77djet";//api key is fake at the moment
$state_ch = curl_init();
curl_setopt($state_ch, CURLOPT_URL, $url);
curl_setopt($state_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($state_ch, CURLOPT_HTTPHEADER, $headers);
$state_result = curl_exec ($state_ch);
$state_result = json_decode($state_result);
$debug = 1;
print_r($state_result);
回复如下
{
"accountId": "fjnfd",
"firstName": "first name",
"lastName": "last name",
"email": "xyz.com@gmail.com",
"phone": "+3798798",
"companyName": "",
"state": "state address",
"city": "city address",
"street": "street address",
"zipCode": "226010",
"countryCode": {
"countryCodeId": "100",
"countryCode": "IN"
},
"industryTag": {
"industryTagId": null
},
"numberOfEmployees": null,
"timeFormat": "12h",
"timeZone": {
"name": "Asia/Kolkata",
"offset": "+09:30"
},
"href": "https://api.getresponse.com/v3/accounts"
}
我没有从 Github 尝试过如何保存数据 GetResponseAPI3.class.php,但它没有发生。
获取响应文档
可以提供帮助的链接
你可以投反对票,但过去 3 天我一直在尝试,但没有发生。
【问题讨论】:
-
Eggzacklee 同样的经历。无法更新联系人。
标签: php api curl php-curl getresponse