2016-11-23 82 views
0

我正在使用API​​。檢查數據是否存在

使用數組我收集的數據是這樣的:

$org_payload = array(
     'name' => $_POST['billing_company'], 
     'phone' => $_POST['billing_phone'], 
     'email' => $_POST['billing_email'], 
     'note' => $_POST['order_comments'], 
     'relation_type' => array(
      'id'=>'relationtype:c1ec3ae77036842d' //provide the relationtypeid, f.e. relationtype:796ce0d318a2f5db515efc18bba82b90 
     ), 
     'visiting_address' => array(
      'country_code'   => 'NL', 
      'line_1'    => $_POST['billing_address_1'], 
      'postal_code'   => $_POST['billing_postcode'], 
      'locality'    => $_POST['billing_city'], 
      'country'    => $_POST['billing_country'] 

     ), // can be extented with other address data 
     'postal_address' => array(
      'country_code'   => 'NL' 
     ) // can be extented with other address data 
); 

在一個點上我這個數據發送到我的工作程序。我通過此代碼實現此目的:

$organization = $SimplicateApi->makeApiCall('POST','/crm/organization',json_encode($org_payload)); 

我從我的網站上的表單收集這些數據。這些數據被髮布在程序中。

我想實現的是,當我從表單收集數據的程序相匹配現有的數據,那麼不加它。我希望爲此提供一個正確的方向提示,一直在網上搜索,沒有任何運氣。

+0

使用'curl'使從PHP POST請求 – Xorifelse

+3

創建自己的數據庫和存儲記錄在那裏。在發佈到API之前,檢查每條提交的記錄與您存儲的內容。 –

+0

@PatrickQ我認爲這是我一直在尋找的答案,謝謝。 –

回答

1

我會建議的是有一個額外的API調用。

就像你在評論中說的 - 公司名稱和電話號碼都是唯一的。 如果有些呼叫通過這些值獲取用戶並檢查您從表單中獲得的內容,就足夠了。

如果它們是唯一的 - 顯示,無論你想在這裏做的用戶或 - 送他們, 如果不是。

無需在系統上再保留一個數據庫。