Hey everyone- I'm looking to use the Ning API in a very simple way. I just need to get the current logged in user's ID so that I can use it to create a custom url link to their profile.
I looked through some of the documentation and found this:
var userid = response.get("oViewer").getData().getId();
(http://developer.ning.com/docs/opensocial/1.0/overview/persistent-data.html#retrieving-data)
Can anyone who's used this tell me if this is going to give me the userId info I'm looking for?
Thanks for your help.
-Ben
Tags:
I've already filed a request for the Ning API to make it easier to find the User ID of the authenticated member.
The 'userid' variable you are setting via OpenSocial is called a 'screenname' in the Ning API. This will allow you to make queries using the author parameter:
GET /User?author=<screenname>
Thanks Devin! So the screen name is the one that is used in a user's profile URL?
Would this be a correct way to grab it?
var userid = GET /User?author=<screenname>
Devin said:
I've already filed a request for the Ning API to make it easier to find the User ID of the authenticated member.
The 'userid' variable you are setting via OpenSocial is called a 'screen name' in the Ning API and it is different from the member's ID. This will allow you to make queries using the author parameter:
GET /User?author=<screenname>
The reason the Ning API has a 'screen name' and a 'user id' is historical. The 'user id' is specific to the Ning Network you are making queries against, while the 'screen name' (also called the Ning ID) is unique to the Ning Platform. We are currently in the process of removing the 'screen name' so the meaning of the field will change over time.
Hi Ben,
You can probably also just do this using some javascript. If you view source on a network page and have a look at the ning js object that gets created, it contains a CurrentProfile object which has an id attribute.
Also, if you just want a link to a signed in user's My Page, you can use /profiles which will redirect them to their actual profile page.
Thanks,
Phil
Sweet, thanks Phil. This looks like it could work for me.
Phil McCluskey said:
Hi Ben,
You can probably also just do this using some javascript. If you view source on a network page and have a look at the ning js object that gets created, it contains a CurrentProfile object which has an id attribute.
Also, if you just want a link to a signed in user's My Page, you can use /profiles which will redirect them to their actual profile page.
Thanks,
Phil
Hi Allyson,
Here's an ultra simple example:
<script type="text/javascript">
alert(ning.CurrentProfile.fullName);
alert(ning.CurrentProfile.photoUrl);
</script>
You should be able to prefill the form variables with the values from those variables.
Thanks,
Phil
Allyson Beckers said:
Could I bother you with an example for that JavaScript?
I have a trivia on my network and I want to automatically pull the logged-in user's name and profile URL to submit with their answer. I am new to JS and can't seem to figure it out.
Your help would be much appreciated!
Phil McCluskey said:Hi Ben,
You can probably also just do this using some javascript. If you view source on a network page and have a look at the ning js object that gets created, it contains a CurrentProfile object which has an id attribute.
Also, if you just want a link to a signed in user's My Page, you can use /profiles which will redirect them to their actual profile page.
Thanks,
Phil
Posted by Kyle Ford on October 13, 2010 at 8:00am 3 Comments 3 Likes
Posted by Phil McCluskey on October 1, 2010 at 8:55am 0 Comments 1 Like
Posted by Kyle Ford on September 30, 2010 at 8:30pm 1 Comment 1 Like
© 2024 Created by Build Team. Powered by