Ning Developer Docs

I feel like this should be really easy, but I couldn't figure out how to do it so far. I want to get a list of all the users (or members, or profiles, I'm not sure the right term) that have registered for my application.

I have tried going to

http://myapp.ning.com/xn/atom/1.0/profile

(of course, replacing "myapp" with the actual name of my application). I get back what seems like a list of all members on Ning. The size is listed as 692,612, and the first entry is "diego". This is definitely not the list for my application, where I am the only one signed up right now.

Can anyone enlighten me on this issue? I'm sure I'm missing something obvious.

Views: 12

Replies to This Discussion

Hi Jason,

We've got a backup script here that you can look at. The next release of the social network code also includes a profile export function.

You could also hit the atom endpoint for the content type of 'User' but you will need to authenticate the call since User objects are private and private objects aren't returned in unauthenticated api calls.

Thanks,
Phil
Thanks for the reply. I am not trying to backup my users, though. I want to be able to show a random set of my application's users on the web site for which I am building the Ning app as a social network. If there were some sort of XML feed of the profiles in my application, I could do it, but it sounds like I am out of luck for now. It does seem a bit odd that I can get a feed of all profiles in Ning, but not the ones that belong to my application. Did I understand that correctly?
Hi Jason,

You can use that same script, and instead of exporting them you can just return the information that you'd like to display and choose a few random ones (using ->order('random')). That should give you what you need.

d
Understood. But I have been trying to stay away from doing any coding on my application itself, just using the API via REST. I will take it into consideration though.
I am actually following through and making a new php page to give me my data feed. Thank you for the suggestion. I don't really know php, but I am figuring enough out to do what I need.

I have one more specific question that I couldn't see the answer to anywhere.

At Diego's suggestion, I tried using $q->order('random()') but it doesn't seem to change order. I added the parentheses after 'random' due to the documentation here:
http://documentation.ning.com/post.php?Post:slug=XN-method_XN_Query...
I also tried it without parentheses. Neither way gave me a random selection of profiles (or more precisely, it might have given me a random set, but it keeps giving me the same set every time I refresh the page). Maybe there's a caching window or something like that that I am not aware of?
Anyone have a thought as to why order('random()') always seems to return the same records, and how I can get around it?
Hi Jason,

The usage would typically look like this:

$content = XN_Query::create('Content')
->filter('type','eic','theType')
->filter('owner')
->order( 'random()' )
->execute()

Is that how you're using it?

Thanks,
Phil
I think so.

Here is the relevant snippet of code:

$q = XN_Query::create('Content')
->filter('owner')
->filter('type','=','User')
->alwaysReturnTotalCount(true);
$q->order('random()');
$q->end($n);
$result = $q->execute();

Note: $n is a variable that I set earlier, to control how many records are returned. I am not 100% sure but I don't think it matters if I put the order('random()') as a separate statement, as I have done, instead of tacking it onto the create call with an arrow the way you have done. If you can see anything wrong with what I have written, or other ideas to try, let me know. The behavior I see is that I do get the right number of records back, and I'm not sure if they are in any kind of order, but I always get back the same ones in the same order.
Hi Jason,

Hmm, yes this seems broken. We'll investigate.

Thanks,
Phil
Thanks Phil. I am now checking in to see if you have made any progress on this. I am sure you have a lot of competing priorities.
Another progress check-in...
Hi Mick,

The random() function isn't something that we can easily provide for social network apps because they run on a different set of core services than the older style Ning apps. The only workaround at this point is to do a query for 100 users, shuffle the results, and then take a slice of a smaller chunk of the shuffled array.

Thanks,
Phil

RSS

© 2026   Created by Ning Developer Admin.   Powered by

Badges  |  Report an Issue  |  Terms of Service