Title

body
 
xxx of yyy characters
Hi5 Platform Development

Watch this Topic   watch
Messages 

1-10 of 14 1 Next > >|

Close Topic

Reason

Message



 
Topic: get all the friends? how?
function sendRequest()
{
var dataResponse;
var req = opensocial.newDataRequest();
req.add (req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), 'viewer');
req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS), 'viewerFriends');
req.send(requestCallback);
}

function requestCallback(response) {
var viewerId = response.get('viewer').getData().getId();
var viewerFriends = response.get('viewerFriends').getData();
document.getElementById('viewer_id').value = viewerId;
makeCanvasPage(viewerFriends);
}

function makeCanvasPage(viewerFriends)
{
document.getElementById('coolpoints_content').innerHTML = "";
//changeTabClass("canvas");
var params = {};
var viewerfriends = gadgets.json.stringify(viewerFriends);
var frnds;
jsonContent = eval("(" + viewerfriends + ")");
for (i = 0; i < jsonContent.array_.length; i++)
{
if (frnds == '' || frnds == undefined)
frnds = jsonContent.array_[i].fields_.id + "," + jsonContent.array_[i].fields_.name.fields_.givenName + "," + jsonContent.array_[i].fields_.thumbnailUrl;
else
frnds += "," + jsonContent.array_[i].fields_.id + "," + jsonContent.array_[i].fields_.name.fields_.givenName + "," + jsonContent.array_[i].fields_.thumbnailUrl;
}
}
this is my code for get viwerfrnds. but i am getting 20 frnds .
Apr 10, 2008
4:15 AM
never mind i got around it.
Apr 10, 2008
6:03 AM
yep...its so strange !!! why 20 and not 21 friends??
Posted by Nelson 
Jul 6, 2008
1:51 AM
Zakir,

can you post your solution here, so that other developers can benefit?

Thanks!
Sameer.
Jul 9, 2008
9:47 AM
thanks Zakir,ou helped me! Believe me i am a total open source lover. Till yesterday i couldnt get all friends. Just 20 friends for every request. Now i know 20 is the default number, and we can define it with this code: var max_results=30; //global variable function make_request_example() { //opensocial NAMESPACE is known by the server //so dont use it in your javascript code! var req = opensocial.newDataRequest(); var opt_params={}; //FIRST friend to fetch opt_params[opensocial.DataRequest.PeopleRequestFields.FIRST]=ini; //next friends to fetch after the FIRST (MAX=50 i supose...??) opt_params[opensocial.DataRequest.PeopleRequestFields.MAX] =max_results; req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS,opt_params), 'viewerFriends'); req.send(onLoadFriends); }; function allprofile(profile,name,id,thumb) { return ""+name+" ID="+id+"
" } function onLoadFriends(dataResponse) { var viewerFriends = dataResponse.get('viewerFriends').getData(); viewerFriends.each(function(person) { var profile_p = person.getField(opensocial.Person.Field.PROFILE_URL); var thumb_p = person.getField(opensocial.Person.Field.THUMBNAIL_URL); var name_p=person.getDisplayName(); var id_p=person.getId(); alert(profile_p+" "+name_p+" "+id_p+" "+thumb_p+"\n" ) }); //important!!!!this gadget installed on the server //will determine the function to make a request!! gadgets.util.registerOnLoadHandler(make_request_example()); ------------------------------------------------- URL: http://218885982.hi5.com/friend/apps/entry/www.hi5.com/friend/apps/developer/app/get/xml/14710
Posted by Nelson 
Jul 9, 2008
7:45 PM
This weekend ill anounce a new forum:
Title: Open Social Applications for HI5.
With many categories : code, manuals, articles so on..

There WE CAN post HTML,Javascript code...!
BEtter than here I supose:S
Posted by Nelson 
Jul 9, 2008
7:50 PM
Should i Met U,
nice nick.sorry to post it too late. but i think this will help you - getting view's frnds.
function sendRequest()
{
var allFriends = {};
allFriends[opensocial.DataRequest.PeopleRequestFields.FIRST] = 1;
allFriends[opensocial.DataRequest.PeopleRequestFields.MAX] = 600;
allFriends[opensocial.DataRequest.PeopleRequestFields.SORT_ORDER] = opensocial.DataRequest.SortOrder.NAME;
var appFriends = {};
appFriends[opensocial.DataRequest.PeopleRequestFields.FIRST] = 1;
appFriends[opensocial.DataRequest.PeopleRequestFields.MAX] = 600;
appFriends[opensocial.DataRequest.PeopleRequestFields.SORT_ORDER] = opensocial.DataRequest.SortOrder.NAME;
appFriends[opensocial.DataRequest.PeopleRequestFields.FILTER] = opensocial.DataRequest.FilterType.HAS_APP;
var dataResponse;
var req = opensocial.newDataRequest();
req.add (req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), 'viewer');
req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS, allFriends), 'viewerFriends');
req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS, appFriends), 'viewerAppFriends');
req.send(requestCallback);
}


function requestCallback(response) {

if ( response.hadError() == false)
{
var viewerId = response.get('viewer').getData().getId();
viewerName = response.get('viewer').getData().getDisplayName();
viewerProfileUrl = response.get('viewer').getData().getField(opensocial.Person.Field.PROFILE_URL);
viewerThumbUrl = response.get('viewer').getData().getField(opensocial.Person.Field.THUMBNAIL_URL);
var viewerFriends = response.get('viewerFriends').getData();
var viewerAppFriends = response.get('viewerAppFriends').getData();

viewerFriends= gadgets.json.stringify(viewerFriends);
viewerAppFriends = gadgets.json.stringify(viewerAppFriends);
//if you want app frnds just use this code with viewerAppFriends
var viewerfriends = gadgets.json.stringify(viewerFriends);
var frnds = '';
var jsonContent = eval("(" + viewerfriends + ")");

for (i = 0; i < jsonContent.array_.length ; i++)
{
if (appfrnds == '' || typeof appfrnds == 'undefined' )
frnds = jsonContent.array_[i].fields_.id + "," + jsonContent.array_[i].fields_.name.fields_.unstructured + "," + jsonContent.array_[i].fields_.thumbnailUrl + "," + jsonContent.array_[i].fields_.profileUrl;
else
frnds += "," + jsonContent.array_[i].fields_.id + "," + jsonContent.array_[i].fields_.name.fields_.unstructured + "," + jsonContent.array_[i].fields_.thumbnailUrl + "," + jsonContent.array_[i].fields_.profileUrl;

}
//now frnds have have views 500 or less frnds.
// you can add name and al the other thing you want in the loop

}
else
{
alert("hi5 and Cool Points are working to fix any problems you are seeing!. Please refresh the page again.");
// remember Sameer !!!
}
}
thnakx againg.

zakir
Jul 9, 2008
9:12 PM
zaquir , i cannot run that code.
what's the gadget to run the function ??

gadgets.util.registerOnLoadHandler(sendRequest())
Posted by Nelson 
Jul 10, 2008
6:15 AM
gadgets.util.registerOnLoadHandler(sendRequest )

???
Posted by Nelson 
Jul 10, 2008
6:15 AM
gadgets.util.registerOnLoadHandler . sendRequest) ?
Posted by Nelson 
Jul 10, 2008
6:15 AM
1-10 of 14 1 Next > >|


Select Language