Ning Developer Network

Hello.

We have online games in our ning website and the games call a PHP script in the same server on ning to upload the scores. The PHP files create an instance of the XN_Profile object like this:
$profile = XN_Profile::current();
$IsOnline = $profile->__get('presence');
if (strtolower($IsOnline) == "online")
$IsOnline = true;
else
$IsOnline = false;

As simple as that. Now the problem is that sometimes although we are logged in, Ning reports that we are not. This usually happens if we leave the session in the browser for a while but this is not necessarily always the case. Does anybody know why this happens with Ning?

Tags: __get, api, class, ning, online, php, presence, profile, user, xn_profile

Share

Replies to This Discussion

Where exactly does it talk about my issue because I can't see such thing.
I have read that document but I don't remember it talking about problems with the "absense" property of the XN_Profile object. Could you please state which part of the documentation you are talking about and how it answers my question?
Yes and that's exactly what I am checking the return value for. I have also changed the characters to all lowercase in case it returns a differnet case of "online", such as "Online" or "onLine" and etc. It returns a null string if the user is not online but the problem is: the user IS online and this method returns a null-string.
Don't know if this will help you or not, but I was just poking around for info on something related to indicating online presence and saw your thread.

There is actually a class XG_PresenceHelper which appears to do the same thing as you are attempting:

class XG_PresenceHelper {

/**
* Returns whether to show the presence indicator for the given profile.
*
* @param XN_Profile The user's profile
* @return boolean Whether permission is granted
*/
public static function canShowPresenceIndicator($profile) {
return $profile->screenName == XN_Profile::current()->screenName || $profile->presence == 'online';
}

}

My guess is that the issue you are confronting is related to the implementation on Ning of how presence is determined. Also, it appears this function is using the same logic as you, so again I doubt it helps much. It might save you a few lines of code and optimize things a bit, since you can just do:


$is_online = XG_PresenceHelper::canShowPresenceIndicator(XG_Cache::profiles($some_user_object->title));

(BTW, this i copy pasted from the source code on Ning which determines whether to display the green "Online" indicator next to someone's profile.)

RSS

© 2009   Created by Ning Developer Admin

Badges  |  Report an Issue  |  Privacy  |  Terms of Service