我在关联数组的形状中得到Pointer<_User>
列字段的对象。现在我想从数组中获取该用户的Object Id,
但是当我尝试这样做时,我收到了一个错误。
数组如下所示:
Parse\ParseUser Object
(
[_sessionToken:protected] =>
[serverData:protected] => Array
(
[__type] => Object
[addallFBfriends] => NO
[autoacceptfriendrequest] => YES
[betsCreated] => 16
[birthday] => DateTime Object
(
[date] => 2015-04-09 07:31:18
[timezone_type] => 2
[timezone] => Z
)
[className] => _User
[credit] => 77
[earning] => 4
[email] => sim1@sim1.com
[firstname] => sim
[friends] => Parse\ParseRelation Object
(
[parent:Parse\ParseRelation:private] => Parse\ParseUser Object
*RECURSION*
[key:Parse\ParseRelation:private] => friends
[targetClassName:Parse\ParseRelation:private] => _User
)
现在假设我想从该数组中获取firstname
所以请帮助我,我怎么能这样做。
答案 0 :(得分:1)
试试这个......
$currentUser = ParseUser::getCurrentUser();
if ($currentUser ) {
// do stuff with the user
echo "|||username= ".$currentUser ->username;
echo "|||email= ".$currentUser ->email;
echo "|||ObjectId= ".$currentUser ->getObjectId();
$sessionToken = ParseUser::getCurrentUser()->getSessionToken();
echo "|||sessionToken= ".$sessionToken;
//print_r($currentUser);
} else {
// show the signup or login page
echo "||no current user please login";
}