现在我正在使用PHP Parse sdk,我正在尝试获取所有用户信息。
$query = ParseUser::query();
$objArray = $query->find();
$data = array();
print_r($objArray);
foreach ($objArray as $obj) {
$one['id'] = $obj->getObjectId();
$one['displayName'] = $obj->displayName;
$one['email'] = $obj->email;
$data[]=$one;
}
这是print_r结果
Array ( [0] => Parse\ParseUser Object ( [_sessionToken:protected] => [serverData:protected] => Array ( [readreceipt] => YES [pushnotification] => YES [usernameFix] => jodydunn [displayName_lower] => jody dunn [displayName] => jody dunn [firstLaunch] => Yes [username] => Judy.Dunn@hotmail.com [userAlreadyAutoFollowedFacebookFriends] => 1 [qbUserID] => 23404642 [verifiedAccount] => 1 ) [operationSet:protected] => Array ( ) [estimatedData:Parse\ParseObject:private] => Array ( [readreceipt] => YES [pushnotification] => YES [usernameFix] => jodydunn [displayName_lower] => jody dunn [displayName] => jody dunn [firstLaunch] => Yes [username] => Judy.Dunn@hotmail.com [userAlreadyAutoFollowedFacebookFriends] => 1 [qbUserID] => 23404642 [verifiedAccount] => 1 ) [dataAvailability:Parse\ParseObject:private] => Array ( [readreceipt] => 1 [pushnotification] => 1 [usernameFix] => 1 [displayName_lower] => 1 [displayName] => 1 [firstLaunch] => 1 [username] => 1 [userAlreadyAutoFollowedFacebookFriends] => 1 [qbUserID] => 1 [verifiedAccount] => 1 ) [className:Parse\ParseObject:private] => _User [objectId:Parse\ParseObject:private] => 97EIKQVlUW [createdAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2017-01-30 14:26:15.568000 [timezone_type] => 2 [timezone] => Z ) [updatedAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2017-06-12 23:34:47.234000 [timezone_type] => 2 [timezone] => Z ) [hasBeenFetched:Parse\ParseObject:private] => 1 ) [1] => Parse\ParseUser Object ( [_sessionToken:protected] => [serverData:protected] => Array ( [username] => tiagomarques304@yahoo.com [displayName_lower] => tiago marques [usernameFix] => tiagomarques [displayName] => Tiago Marques [firstLaunch] => Yes [readreceipt] => YES [pushnotification] => YES [facebookId] => 1722892281374124 [qbUserID] => 23295999 ) [operationSet:protected] => Array ( ) [estimatedData:Parse\ParseObject:private] => Array ( [username] => tiagomarques304@yahoo.com [displayName_lower] => tiago marques [usernameFix] => tiagomarques [displayName] => Tiago Marques [firstLaunch] => Yes [readreceipt] => YES [pushnotification] => YES [facebookId] => 1722892281374124 [qbUserID] => 23295999 ) [dataAvailability:Parse\ParseObject:private] => Array ( [username] => 1 [displayName_lower] => 1 [usernameFix] => 1 [displayName] => 1 [firstLaunch] => 1 [readreceipt] => 1 [pushnotification] => 1 [facebookId] => 1 [qbUserID] => 1 ) [className:Parse\ParseObject:private] => _User [objectId:Parse\ParseObject:private] => nOsEiFmpLu [createdAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2017-01-27 16:11:18.737000 [timezone_type] => 2 [timezone] => Z ) [updatedAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2017-01-27 16:11:37.865000 [timezone_type] => 2 [timezone] => Z ) [hasBeenFetched:Parse\ParseObject:private] => 1 ) [2] => Parse\ParseUser Object ( [_sessionToken:protected] => [serverData:protected] => Array ( [displayName_lower] => jody dunn [firstLaunch] => Yes [displayName] => jody dunn [usernameFix] => jodydunn [username] => jody.dunn@hotmail.com [readreceipt] => YES [pushnotification] => YES [userAlreadyAutoFollowedFacebookFriends] => 1 [qbUserID] => 23158732 [verifiedAccount] => 1 ) [operationSet:protected] => Array ( ) [estimatedData:Parse\ParseObject:private] => Array ( [displayName_lower] => jody dunn [firstLaunch] => Yes [displayName] => jody dunn [usernameFix] => jodydunn [username] => jody.dunn@hotmail.com [readreceipt] => YES [pushnotification] => YES [userAlreadyAutoFollowedFacebookFriends] => 1 [qbUserID] => 23158732 [verifiedAccount] => 1 ) [dataAvailability:Parse\ParseObject:private] => Array ( [displayName_lower] => 1 [firstLaunch] => 1 [displayName] => 1 [usernameFix] => 1 [username] => 1 [readreceipt] => 1 [pushnotification] => 1 [userAlreadyAutoFollowedFacebookFriends] => 1 [qbUserID] => 1 [verifiedAccount] => 1 ) [className:Parse\ParseObject:private] => _User [objectId:Parse\ParseObject:private] => VtvElOtqFQ [createdAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2017-01-24 11:47:08.461000 [timezone_type] => 2 [timezone] => Z ) [updatedAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2017-06-12 23:34:24.014000 [timezone_type] => 2 [timezone] => Z ) [hasBeenFetched:Parse\ParseObject:private] => 1 ) [3] => Parse\ParseUser Object ( [_sessionToken:protected] => [serverData:protected] => Array ( [displayName] => Jody dunn [pushnotification] => YES [readreceipt] => YES [username] => Jody.dunn@hotmail.com [firstLaunch] => Yes [usernameFix] => jodydunn [displayName_lower] => jody dunn [userAlreadyAutoFollowedFacebookFriends] => 1 [qbUserID] => 22885014 ) [operationSet:protected] => Array ( ) [estimatedData:Parse\ParseObject:private] => Array ( [displayName] => Jody dunn [pushnotification] => YES [readreceipt] => YES [username] => Jody.dunn@hotmail.com [firstLaunch] => Yes [usernameFix] => jodydunn [displayName_lower] => jody dunn [userAlreadyAutoFollowedFacebookFriends] => 1 [qbUserID] => 22885014 ) [dataAvailability:Parse\ParseObject:private] => Array ( [displayName] => 1 [pushnotification] => 1 [readreceipt] => 1 [username] => 1 [firstLaunch] => 1 [usernameFix] => 1 [displayName_lower] => 1 [userAlreadyAutoFollowedFacebookFriends] => 1 [qbUserID] => 1 ) [className:Parse\ParseObject:private] => _User [objectId:Parse\ParseObject:private] => oBBU5lwrAk [createdAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2017-01-17 23:09:42.008000 [timezone_type] => 2 [timezone] => Z ) [updatedAt:Parse\ParseObject:private] => DateTime Object ( [date] => 2017-01-17 23:09:46.529000 [timezone_type] => 2 [timezone] => Z ) [hasBeenFetched:Parse\ParseObject:private] => 1 )
所以我可以获得其他字段,但没有现有的电子邮件。
我如何收到电子邮件。请告诉我。
答案 0 :(得分:0)
您要查找的电子邮件属性是ParseUser
实例上的可选属性。在假设它存在之前,你应该检查它是否存在。
如果您在注册时使用,则唯一必填字段为密码和用户名。如果未事先提供并设置电子邮件(例如通过$user->setEmail('...')
),则之后将无法访问。
据说,用户名属性是您在用户上收到有效电子邮件的最佳选择,假设他们使用电子邮件注册了用户名。除此之外,您始终可以要求您的用户在注册时提交电子邮件,或者要求用户名是电子邮件(效果非常好!)。
答案 1 :(得分:0)
电子邮件字段确实存在,您只需要masterKey即可获得它。
使用$query->find( true );
并向masterKey提供ParseClient::initialize
,您应该收到电子邮件。