我正在使用FullContact读卡器API。根据我在处理名片时的要求,我需要向FullContact API发送名片图像和webhook。
发送脚本:
<?php
$APIkey = 'my FullContact api key';
$callback_url = 'https://www.my-domain.com/my-callback-listener.php';
$url = "https://api.fullcontact.com/v2/cardReader?format=json&webhookUrl=$callback_url;
$imageAsBase64 = base64_encode(file_get_contents('path-to-image-including-extension'));
$requestBody = array();
$requestBody['front'] = $imageAsBase64;
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, $url);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($connection, CURLOPT_POST, true);
curl_setopt($connection, CURLOPT_POSTFIELDS, json_encode($requestBody));
curl_setopt($connection, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'X-FullContact-APIKey: $APIkey'));
$result = curl_exec($connection);
echo json_encode(array('result' => $result));
?>
回调监听器脚本:
<?php
header('HTTP/1.1 200 OK');
?>
我知道发送脚本正在运行,因为curl结果包含FullContact API分配的id。然后,当我通过在浏览器中手动输入以下URL来引用该ID时:
https://api.fullcontact.com/v2/cardReader/{id-assigned-from-FullContact}?apiKey={my-FullContact-api-key}
这是我收到的:
{
"id": "id-assigned-from-FullContact",
"lastWebhookAttempt": "2017-03-20T18:41:57.000Z",
"vCardUrl": "https://d1h3f0foa0xzdz.cloudfront.net/2971518/special-link-to-vcf-card.vcf",
"status": "CALLBACK_FAILED",
"webhookAttempts": 5,
"webhookUrl": "https://www.my-domain.com/my-callback-listener.php",
"quality": "LOW",
"submitted": "2017-03-20T18:28:27.000Z",
"contact": {
"photos": [{
"primary": true,
"value": "https://d1h3f0foa0xzdz.cloudfront.net/2971518/special-link-to-image-of-business-card.png",
"type": "BusinessCard"
}],
"organizations": [{
"title": "Senior Sales Consultant",
"isPrimary": true,
"name": "Company ABC"
}],
"name": {
"middleName": null,
"honorificPrefix": null,
"familyName": "Meek",
"givenName": "Jack",
"honorificSuffix": null
},
"emails": [{
"value": "person@something.com",
"type": "Work"
}],
"phoneNumbers": [
{
"value": "+1 123-987-6543 ext. 5159069",
"type": "Work"
},
{
"value": "+1 123-456-6789",
"type": "Mobile"
},
{
"value": "886 123-4567",
"type": "Work Fax"
}
],
"addresses": [{
"region": null,
"streetAddress": "1234 Nowhere Dr,",
"formatted": null,
"postalCode": "48377",
"extendedAddress": null,
"locality": "Novi",
"type": "Work",
"country": "United States"
}]
}
}
您可以在上面的结果中看到FullContact API尝试调用我的回调侦听器脚本,最终导致CALLBACK_FAILED
。但是,我的回调脚本只包含HTTP/1.1 200 OK
,它应该可以正常工作。这告诉我由于某种原因我的回调脚本无法访问。我的网站使用他们的共享托管平台SSL在GoDaddy上托管。
任何人都知道GoDaddy是否会阻止某些网络流量流量?任何帮助将不胜感激!
我尝试查看FullContact文档但是,它未能提供有关webhooks如何发回数据的任何明确细节。
答案 0 :(得分:1)
所以我最终联系了我的网络主机(GoDaddy)和FullContact。我有一个与GoDaddy共享的托管平台,所以他们限制了大量的端口号。 FullContact向我保证他们只使用端口80或443。
要解决这个问题,我最终必须创建一个本地xampp服务器并将其公之于众。然后我指示FullContact使用我的本地服务器作为我的webhook。
我运行了一些测试并使用php来提取IP地址,主机名和端口号。结果如下:
测试1。
主办地址:52.70.48.63
主持人姓名:ec2-52-70-48-63.compute-1.amazonaws.com
端口号:63498
测试2。
主办地址:52.70.48.63
主持人姓名:ec2-52-70-48-63.compute-1.amazonaws.com
端口号:4169
测试3。
主办地址:52.70.48.63
主持人姓名:ec2-52-70-48-63.compute-1.amazonaws.com
端口号:61425
返回的所有端口号都被GoDaddy阻止。我从FullContact接收数据的唯一方法是使用我的本地服务器。案件结案。希望有一天这最终帮助了某人!