بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
یک کد json
سلام ایا این کد جسیون هست؟
اگر نیس چی هس؟یه برنامه دارم داره اینو دریافت میکنه!چجوری؟
<data><user userKey='16' /><friend username = 'test2'
status='offline' IP='5.22.50.176' userKey = '17' port='15145'
authenticationTime ='2014-11-14 17:19:57' wall='love' /></data>
برای این سوال 1 پاسخ وجود دارد.
پاسخ به سوال
سجاد زهره ای
11 سال پیش
0
0
if ($userId = authenticateUser($db, $username, $password))
{
// providerId and requestId is Id of a friend pair,
// providerId is the Id of making first friend request
// requestId is the Id of the friend approved the friend request made by providerId
// fetching friends,
// left join expression is a bit different,
// it is required to fetch the friend, not the users itself
$sql = "select u.Id, u.username, (NOW()-u.authenticationTime)
as authenticateTimeDifference, u.IP,u.authenticationTime,u.wall,
f.providerId, f.requestId, f.status, u.port
from friends f
left join users u on
u.Id = if ( f.providerId = ".$userId.", f.requestId, f.providerId )
where (f.providerId = ".$userId." and f.status=".USER_APPROVED.") or
f.requestId = ".$userId." ";
$sqlmessage = "SELECT m.id, m.fromuid, m.touid, m.sentdt, m.read, m.readdt,
m.messagetext, u.username from messages m \n"
. "left join users u on u.Id = m.fromuid WHERE `touid` = ".$userId." AND `read` = 0
LIMIT 0, 30 ";
if ($result = $db->query($sql))
{
$out .= "<data>";
$out .= "<user userKey='".$userId."' />";
while ($row = $db->fetchObject($result))
{
$status = "offline";
if (((int)$row->status) == USER_UNAPPROVED)
{
$status = "unApproved";
}
else if (((int)$row->authenticateTimeDifference) < TIME_INTERVAL_FOR_USER_STATUS)
{
$status = "online";
}
$out .= "<friend username = '".$row->username."' status='".$status."' IP='".$row->IP."' userKey = '".$row->Id."' port='".$row->port."' authenticationTime ='".$row->authenticationTime."' wall='".$row->wall."' />";
// to increase security, we need to change userKey periodically and pay more attention
// receiving message and sending message
}
if ($resultmessage = $db->query($sqlmessage))
{
while ($rowmessage = $db->fetchObject($resultmessage))
{
$out .= "<message from='".$rowmessage->username."' sendt='".$rowmessage->sentdt."' text='".$rowmessage->messagetext."' />";
$sqlendmsg = "UPDATE `messages` SET `read` = 1, `readdt` = '".DATE("Y-m-d H:i")."' WHERE `messages`.`id` = ".$rowmessage->id.";";
$db->query($sqlendmsg);
}
}
$out .= "</data>";
}
else
{
$out = FAILED;
}
}
else
{
// exit application if not authenticated user
$out = FAILED;
}
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .
messagesWHEREtouid= ".$userId." ANDread= 0 LIMIT 0, 30 "; $sqlmessage = "SELECT m.id, m.fromuid, m.touid, m.sentdt, m.read, m.readdt, m.messagetext, u.username from messages m \n" . "left join users u on u.Id = m.fromuid WHEREtouid= ".$userId." ANDread= 0 LIMIT 0, 30 "; if ($result = $db->query($sql)) { $out .= ""; $out .= ""; while ($row = $db->fetchObject($result)) { $status = "offline"; if (((int)$row->status) == USER_UNAPPROVED) { $status = "unApproved"; } else if (((int)$row->authenticateTimeDifference) < TIME_INTERVAL_FOR_USER_STATUS) { $status = "online"; } $out .= ""; لینک to increase security, we need to change userKey periodically and pay more attention لینک receiving message and sending message } if ($resultmessage = $db->query($sqlmessage)) { while ($rowmessage = $db->fetchObject($resultmessage)) { $out .= ""; $sqlendmsg = "UPDATEmessagesSETread= 1,readdt= '".DATE("Y-m-d H:i")."' WHEREmessages.id= ".$rowmessage->id.";"; $db->query($sqlendmsg); } } $out .= ""; } else { $out = FAILED; } } else { لینک exit application if not authenticated user $out = FAILED; } (11 سال پیش)