我正在使用FullContact讀卡器API。根據我在處理名片時發出的請求,我需要向FullContact API發送名片圖像以及webhook。FullContact 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');
?>
我知道發送腳本工作,因爲捲曲的結果包含由FullContact API分配一個ID。然後,當我引用ID手動鍵入以下URL我的瀏覽器:
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": "[email protected]",
"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是看使5次嘗試呼叫我的回調監聽器腳本最終導致CALLBACK_FAILED
。但是,我的回調腳本只包含HTTP/1.1 200 OK
,它應該可以正常工作。這告訴我由於某種原因我的回調腳本不可訪問。我的網站使用他們的共享主機平臺SSL在GoDaddy上託管。
任何人都知道,如果GoDaddy阻止某些webhook流量?任何幫助,將不勝感激!
我嘗試過查看FullContact文檔,但沒有提供任何有關webhooks如何發回數據的明確細節。
嘿,你解決了這個錯誤。我的webhook網址也無法使用。 –
@sujal原來GoDaddy吸球。我建立了一個本地服務器進行測試,它運行得非常好。然後我將我的主機切換到另一個提供商「fastComet」。如果切換確保他們不限制像GoDaddy那樣的端口。 – Austin
您的服務器是最可能出現的問題。如果您確定它不是服務器問題,請在此處發佈您的代碼。可能是一個編碼問題。 – Austin