[tuxdroid-svn] r4662 - software_suite_v2/software/gadgets/tuxdroid-gadget-facebook/trunk/tuxdroid-g
Status: Beta
Brought to you by:
ks156
|
From: jerome <c2m...@c2...> - 2009-05-25 12:00:15
|
Author: jerome Date: 2009-05-25 14:00:06 +0200 (Mon, 25 May 2009) New Revision: 4662 Added: software_suite_v2/software/gadgets/tuxdroid-gadget-facebook/trunk/tuxdroid-gadget-facebook/src/FacebookFunctions.java Log: * Getting user friend list. Added: software_suite_v2/software/gadgets/tuxdroid-gadget-facebook/trunk/tuxdroid-gadget-facebook/src/FacebookFunctions.java =================================================================== --- software_suite_v2/software/gadgets/tuxdroid-gadget-facebook/trunk/tuxdroid-gadget-facebook/src/FacebookFunctions.java (rev 0) +++ software_suite_v2/software/gadgets/tuxdroid-gadget-facebook/trunk/tuxdroid-gadget-facebook/src/FacebookFunctions.java 2009-05-25 12:00:06 UTC (rev 4662) @@ -0,0 +1,86 @@ +import java.io.IOException; +import java.util.EnumSet; +import java.util.List; +import java.util.Vector; + +import com.facebook.api.FacebookException; +import com.facebook.api.ProfileField; +import com.facebook.api.schema.FriendsGetResponse; +import com.facebook.api.schema.User; +import com.facebook.api.schema.UsersGetInfoResponse; + +/* This file is part of "TuxDroid Gadget Facebook". + * Copyright 2009, kysoh + * Author : Conan Jerome. + * eMail : jer...@ky... + * Site : http://www.kysoh.com/ + * + * "TuxDroid Gadget Facebook" is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * "TuxDroid Gadget Facebook" is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with "TuxDroid Gadget Facebook"; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +public class FacebookFunctions { + + private FacebookConnection connection; + + /** + * Class constructor. + * @param connection + */ + public FacebookFunctions(FacebookConnection connection) + { + this.connection = connection; + } + + + /** + * Return the user friend list as Vector<String>. + * @return + */ + private Vector<String> getFriends() + { + Vector<String> friendsList = new Vector<String>(); + + try + { + // Get friends list + connection.getClient().friends_get(); + FriendsGetResponse response = (FriendsGetResponse) connection.getClient().getResponsePOJO(); + List<Long> friends = response.getUid(); + + // Go fetch the information for the user list of user ids + connection.getClient().users_getInfo(friends, EnumSet.of(ProfileField.NAME)); + + UsersGetInfoResponse userResponse = (UsersGetInfoResponse) connection.getClient().getResponsePOJO(); + + // Print out the user information + List<User> users = userResponse.getUser(); + for (User user : users) + { + friendsList.add(user.getName()); + } + } + catch (FacebookException e) + { + return null; + } + catch (IOException e) + { + return null; + } + + return friendsList; + } +} |