1 <?xml version="1.0" encoding="UTF-8"?>
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 <ModulePrefs title="List Friends using HAS_APP filter Example">
22 <Require feature="opensocial-0.7"/>
26 <script type="text/javascript">
29 * Request for friend information.
32 var req = opensocial.newDataRequest();
34 req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.OWNER), 'owner');
36 params[opensocial.DataRequest.PeopleRequestFields.MAX] = 50;
37 params[opensocial.DataRequest.PeopleRequestFields.FILTER] = opensocial.DataRequest.FilterType.HAS_APP;
38 params[opensocial.DataRequest.PeopleRequestFields.SORT_ORDER] = opensocial.DataRequest.SortOrder.NAME;
39 req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.OWNER_FRIENDS, params), 'ownerFriends');
40 req.send(onLoadFriends);
44 * Parses the response to the friend information request and generates
45 * html to list the friends along with their display name.
47 * @param {Object} dataResponse Friend information that was requested.
49 function onLoadFriends(dataResponse) {
50 var owner = dataResponse.get('owner').getData();
51 var html = 'Friends of ' + owner.getDisplayName();
53 var ownerFriends = dataResponse.get('ownerFriends').getData();
54 ownerFriends.each(function(person) {
55 html += '<li>' + person.getDisplayName() + '</li>';
58 document.getElementById('message').innerHTML = html;
61 gadgets.util.registerOnLoadHandler(getData);
63 <div id="message"> </div>