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.
(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.
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 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?
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.
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?
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.
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.