我有一个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));
我希望在数组项名称已经存在时使其回显一些东西。
所有新输入的数据都以json格式存储在此网址中:
/ API / V2 / CRM /组织
get请求如下所示:
$test = $SimplicateApi->makeApiCall('GET','/api/v2/crm/organization?q');
以下是伪代码中我想要的示例:
if(name already exists){
echo 'this name already exists'
} else {
//Post it
$organization = $SimplicateApi->makeApiCall('POST','/crm/organization',json_encode($org_payload));
}
答案 0 :(得分:1)
if (array_key_exists('name', $org_payload)) {
// do something
echo 'this name already exists'
} else {
// make API call
}