我需要检查哪些通讯录用户正在使用我的 iOS 应用程序(使用他们的电子邮件)。为此,我将联系人列表发送到我的 PHP 服务器并检查已注册的电子邮件。然后,我返回一组用户并在 iOS TableView 中显示他们。问题是当我有 100-200 个联系人时,检索速度很快,但是当我有 1000-1500 个联系人时,至少需要 3-4 分钟。我该如何改进它?
PHP code:
$handle = fopen('php://input','r');
$jsonInput = fgets($handle);
// Decoding JSON into an Array
$array = json_decode($jsonInput,true);
if (empty($array)) {
echo '<h1>Array is Empty!!!<h1>';
return;
}
require('DBconnection.php');
$DBconnection = new DBconnection;
$link = $DBconnection->connectToDatabase();
if ($link)
{
$DBconnection->selectDatabase();
foreach($array as $subArray)
{
foreach($subArray['email'] as $email)
{
$query="SELECT email,picture from User WHERE email='$email'";
$result= mysql_query($query);
$row = mysql_fetch_assoc($result);
if(mysql_num_rows($result) > 0)//if it finds any row
{
$Contact = array(
"fullname" => $subArray['fullname'],
"email" => $email,
"picture" => "http://www.mysite.co/Project/Users/Images/".$email."."."jpg"."?".time()
);
$ReturningArray[] = $Contact;
}
}
}
echo json_encode($ReturningArray);
}