提交给contacts/bulk
操作的联系人(描述为here)将其放入回复中显示的invalids
集合中会出现什么问题?
当我超过引用here的字段长度时,SurveyMonkey只会截断字段并将其返回successful
集合中。如果我在电子邮件地址中放入了无效字符,则只会返回500错误。
答案 0 :(得分:0)
<?php
include_once("connect.php");
function generateRandomString($length = 6) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
$random = generateRandomString();
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$ip_check = $conn->query"SELECT id FROM users WHERE ip = '" . $ip . "'";
if(!$ip_check) {
die('Query failed to execute');
}
if($ip_check->num_rows == 1) {
echo "User exists";
$user = mysql_fetch_array($ip_check);
echo $user;
} else {
echo "User doesnt exist";
$sql = "INSERT INTO users (ip, code) VALUES ('" . $ip ."', '" . $random . "')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
密钥用于无效的电子邮件,基本上是与某些电子邮件验证正则表达式不匹配的电子邮件。
所以,如果你发布像
这样的东西invalids
那应该进入{
"contacts": [{
"first_name": "Test",
"last_name": "Example",
"email": "notanemail"
}]
}
列表。如果无效字符导致500,那么我将向SurveyMonkey的API支持报告错误。