Author: thomasvm
Date: 2007-03-30 13:45:41 -0500 (Fri, 30 Mar 2007)
New Revision: 75227
Added:
trunk/facebook-sharp/examples/GetEvents.cs
trunk/facebook-sharp/examples/GetFriends.cs
trunk/facebook-sharp/src/Mono.Facebook/Event.cs
trunk/facebook-sharp/src/Mono.Facebook/Friend.cs
trunk/facebook-sharp/src/Mono.Facebook/FriendInfo.cs
trunk/facebook-sharp/src/Mono.Facebook/Group.cs
trunk/facebook-sharp/src/Mono.Facebook/Location.cs
trunk/facebook-sharp/src/Mono.Facebook/Notification.cs
trunk/facebook-sharp/src/Mono.Facebook/PeopleList.cs
trunk/facebook-sharp/src/Mono.Facebook/User.cs
Modified:
trunk/facebook-sharp/ChangeLog
trunk/facebook-sharp/examples/Makefile.am
trunk/facebook-sharp/src/Makefile.am
trunk/facebook-sharp/src/Mono.Facebook/Album.cs
trunk/facebook-sharp/src/Mono.Facebook/FacebookParam.cs
trunk/facebook-sharp/src/Mono.Facebook/FacebookSession.cs
trunk/facebook-sharp/src/Mono.Facebook/Responses.cs
trunk/facebook-sharp/src/Mono.Facebook/Util.cs
Log:
2007-03-30 Thomas Van Machelen <[EMAIL PROTECTED]>
A big code drop to implement the missing methods of the facebook api.
This work is a merge of my work with various pieces of code by George
Talusan ([EMAIL PROTECTED]) which improved mine. Thank you, George.
* src/Mono.Facebook/Album.cs:
use static method to create parameters
* src/Mono.Facebook/Event.cs:
* src/Mono.Facebook/Friend.cs:
* src/Mono.Facebook/FriendInfo.cs:
* src/Mono.Facebook/Group.cs:
* src/Mono.Facebook/FacebookSession.cs:
* src/Mono.Facebook/Location.cs:
* src/Mono.Facebook/Notification.cs:
* src/Mono.Facebook/PeopleList.cs:
* src/Mono.Facebook/Responses.cs:
* src/Mono.Facebook/User.cs:
Add methods and classes for retrieving information for events,
friends, groups, notifications and users. This way the
following methods are also implemented now:
* src/Makefile.am: add new files to build
* src/Mono.Facebook/FacebookParam.cs:
Add support for handling arrays as value and hide constructor
so that one needs to call FacebookParam.Create to obtain a
parameter
Modified: trunk/facebook-sharp/ChangeLog
===================================================================
--- trunk/facebook-sharp/ChangeLog 2007-03-30 18:42:27 UTC (rev 75226)
+++ trunk/facebook-sharp/ChangeLog 2007-03-30 18:45:41 UTC (rev 75227)
@@ -1,3 +1,38 @@
+2007-03-30 Thomas Van Machelen <[EMAIL PROTECTED]>
+ A big code drop to implement the missing methods of the facebook api.
+ This work is a merge of my work with various pieces of code by George
+ Talusan ([EMAIL PROTECTED]) which improved mine. Thank you, George.
+
+ * src/Mono.Facebook/Album.cs:
+ use static method to create parameters
+
+ * src/Mono.Facebook/Event.cs:
+ * src/Mono.Facebook/Friend.cs:
+ * src/Mono.Facebook/FriendInfo.cs:
+ * src/Mono.Facebook/Group.cs:
+ * src/Mono.Facebook/FacebookSession.cs:
+ * src/Mono.Facebook/Location.cs:
+ * src/Mono.Facebook/Notification.cs:
+ * src/Mono.Facebook/PeopleList.cs:
+ * src/Mono.Facebook/Responses.cs:
+ * src/Mono.Facebook/User.cs:
+ Add methods and classes for retrieving information for events,
+ friends, groups, notifications and users. This way the
+ following methods are also implemented now:
+
+ * src/Makefile.am: add new files to build
+
+ * src/Mono.Facebook/FacebookParam.cs:
+ Add support for handling arrays as value and hide constructor
+ so that one needs to call FacebookParam.Create to obtain a
+ parameter
+
+ * examples/GetFriends.cs:
+ * examples/GetEvents.cs:
+ * examples/Makefile.am:
+ Added examples by George Talusan to demonstrate the new
+ methods
+
2007-03-27 George Talusan <[EMAIL PROTECTED]>
* src/Mono.Facebook/Util.cs: fix the way the response stream is read,
the old implementation sometimes caused the deserialization to fail
Added: trunk/facebook-sharp/examples/GetEvents.cs
===================================================================
--- trunk/facebook-sharp/examples/GetEvents.cs 2007-03-30 18:42:27 UTC (rev
75226)
+++ trunk/facebook-sharp/examples/GetEvents.cs 2007-03-30 18:45:41 UTC (rev
75227)
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using Mono.Facebook;
+
+namespace Mono.Facebook.Test
+{
+ class GetEvents
+ {
+ static void Main(string[] args)
+ {
+ // create session
+ FacebookSession session = new
FacebookSession("ca9511b32569d823f1d3a942b31c6c84",
"61f4712317fb7a2d12581f523c01fe71");
+
+ // create token and login with it
+ Uri login = session.CreateToken();
+ System.Diagnostics.Process.Start("firefox",
login.AbsoluteUri);
+ Console.WriteLine ("Press enter after you've logged
in.");
+ Console.ReadLine ();
+
+ // get session key
+ session.GetSession ();
+
+ Me me = session.GetLoggedInUser ();
+ foreach (Event e in me.Events) {
+ Console.WriteLine ("Event Name: {0}", e.Name);
+ Console.WriteLine ("Attending: {0}",
e.MemberList.Attending.Length);
+ }
+ }
+ }
+}
Added: trunk/facebook-sharp/examples/GetFriends.cs
===================================================================
--- trunk/facebook-sharp/examples/GetFriends.cs 2007-03-30 18:42:27 UTC (rev
75226)
+++ trunk/facebook-sharp/examples/GetFriends.cs 2007-03-30 18:45:41 UTC (rev
75227)
@@ -0,0 +1,27 @@
+using System;
+using Mono.Facebook;
+
+namespace Mono.Facebook.Test
+{
+ class GetFriends
+ {
+ static void Main(string[] args)
+ {
+ // create session
+ FacebookSession session = new
FacebookSession("ca9511b32569d823f1d3a942b31c6c84",
"61f4712317fb7a2d12581f523c01fe71");
+
+ // create token and login with it
+ Uri login = session.CreateToken();
+ System.Diagnostics.Process.Start("firefox",
login.AbsoluteUri);
+ Console.WriteLine ("Press enter after you've logged
in.");
+ Console.ReadLine ();
+
+ // get session key
+ session.GetSession();
+
+ Friend[] friends = session.GetFriends();
+ foreach (Friend friend in friends)
+ Console.WriteLine (friend.UId);
+ }
+ }
+}
Modified: trunk/facebook-sharp/examples/Makefile.am
===================================================================
--- trunk/facebook-sharp/examples/Makefile.am 2007-03-30 18:42:27 UTC (rev
75226)
+++ trunk/facebook-sharp/examples/Makefile.am 2007-03-30 18:45:41 UTC (rev
75227)
@@ -1,4 +1,4 @@
-SAMPLES=GetAlbums.cs
+SAMPLES=GetAlbums.cs GetFriends.cs GetEvents.cs
MCSFLAGS= -debug -nologo -r:Mono.Facebook.dll
EXTRA_DIST=$(SAMPLES)
Modified: trunk/facebook-sharp/src/Makefile.am
===================================================================
--- trunk/facebook-sharp/src/Makefile.am 2007-03-30 18:42:27 UTC (rev
75226)
+++ trunk/facebook-sharp/src/Makefile.am 2007-03-30 18:45:41 UTC (rev
75227)
@@ -13,13 +13,21 @@
monofacebook_sources = \
Mono.Facebook/Album.cs \
Mono.Facebook/AssemblyInfo.cs \
+ Mono.Facebook/Event.cs \
Mono.Facebook/FacebookException.cs \
Mono.Facebook/FacebookParam.cs \
Mono.Facebook/FacebookSession.cs \
+ Mono.Facebook/Friend.cs \
+ Mono.Facebook/FriendInfo.cs \
+ Mono.Facebook/Group.cs \
+ Mono.Facebook/Location.cs \
+ Mono.Facebook/Notification.cs \
+ Mono.Facebook/PeopleList.cs \
Mono.Facebook/Photo.cs \
Mono.Facebook/Responses.cs \
Mono.Facebook/SessionWrapper.cs \
Mono.Facebook/Tag.cs \
+ Mono.Facebook/User.cs \
Mono.Facebook/Util.cs
monofacebook_build_sources = $(addprefix $(srcdir)/, $(monofacebook_sources))
Modified: trunk/facebook-sharp/src/Mono.Facebook/Album.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/Album.cs 2007-03-30 18:42:27 UTC
(rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/Album.cs 2007-03-30 18:45:41 UTC
(rev 75227)
@@ -1,5 +1,5 @@
//
-// Mono.Facebook.Albums.cs:
+// Mono.Facebook.Album.cs:
//
// Authors:
// Thomas Van Machelen ([EMAIL PROTECTED])
@@ -73,7 +73,8 @@
public Photo[] GetPhotos ()
{
- PhotosResponse rsp =
Session.Util.GetResponse<PhotosResponse> ("facebook.photos.get", new
FacebookParam ("aid", AId),
+ PhotosResponse rsp =
Session.Util.GetResponse<PhotosResponse> ("facebook.photos.get",
+ FacebookParam.Create ("aid", AId),
FacebookParam.Create ("session_key",
Session.SessionKey),
FacebookParam.Create ("call_id",
DateTime.Now.Ticks));
@@ -94,7 +95,8 @@
pids.Append (p.PId);
}
- PhotoTagsResponse rsp =
Session.Util.GetResponse<PhotoTagsResponse> ("facebook.photos.getTags", new
FacebookParam ("pids", pids),
+ PhotoTagsResponse rsp =
Session.Util.GetResponse<PhotoTagsResponse> ("facebook.photos.getTags",
+ FacebookParam.Create ("pids", pids),
FacebookParam.Create ("session_key",
Session.SessionKey),
FacebookParam.Create ("call_id",
System.DateTime.Now.Ticks));
@@ -114,3 +116,4 @@
}
}
}
+
Added: trunk/facebook-sharp/src/Mono.Facebook/Event.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/Event.cs 2007-03-30 18:42:27 UTC
(rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/Event.cs 2007-03-30 18:45:41 UTC
(rev 75227)
@@ -0,0 +1,145 @@
+//
+// Mono.Facebook.Event.cs:
+// // Authors:
+// George Talusan ([EMAIL PROTECTED])
+//
+
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Xml.Serialization;
+using System.Text;
+
+namespace Mono.Facebook
+{
+ public class EventMemberList
+ {
+ public Friend[] Attending;
+
+ public Friend[] Unsure;
+
+ public Friend[] Declined;
+
+ public Friend[] NotReplied;
+ }
+
+ public class Event : SessionWrapper
+ {
+ [XmlElement ("eid")]
+ public long EId;
+
+ [XmlElement ("name")]
+ public string Name;
+
+ [XmlElement ("tagline")]
+ public string Tagline;
+
+ [XmlElement ("nid")]
+ public long NId;
+
+ [XmlElement ("pic")]
+ public string Pic;
+
+ [XmlIgnore ()]
+ public Uri PicUri
+ {
+ get { return new Uri (Pic); }
+ }
+
+ [XmlElement ("pic_big")]
+ public string PicBig;
+
+ [XmlIgnore ()]
+ public Uri PicBigUri
+ {
+ get { return new Uri (PicBig); }
+ }
+
+ [XmlElement ("pic_small")]
+ public string PicSmall;
+
+ [XmlIgnore ()]
+ public Uri PicSmallUri
+ {
+ get { return new Uri (PicSmall); }
+ }
+
+ [XmlElement ("host")]
+ public string Host;
+
+ [XmlElement ("description")]
+ public string Description;
+
+ [XmlElement ("event_type")]
+ public string EventType;
+
+ [XmlElement ("event_subtype")]
+ public string EventSubType;
+
+ [XmlElement ("start_time")]
+ public long StartTime;
+
+ [XmlElement ("end_time")]
+ public long EndTime;
+
+ [XmlElement ("creator")]
+ public long? Creator;
+
+ [XmlElement ("update_time")]
+ public long UpdateTime;
+
+ [XmlElement ("location")]
+ public string Location;
+
+ [XmlElement ("venue")]
+ public Location Venue;
+
+ [XmlIgnore ()]
+ public EventMemberList MemberList {
+ get {
+ EventMembersResponse rsp =
Session.Util.GetResponse<EventMembersResponse> ("facebook.events.getMembers",
+ FacebookParam.Create ("session_key",
Session.SessionKey),
+ FacebookParam.Create ("call_id",
DateTime.Now.Ticks),
+ FacebookParam.Create ("eid", EId));
+
+ EventMemberList list = new EventMemberList ();
+
+ list.Attending = new Friend
[rsp.Attending.UIds.Length];
+ for (int i = 0; i < list.Attending.Length; i++)
+ list.Attending[i] = new Friend
(rsp.Attending.UIds [i], this.Session);
+
+ list.Unsure = new Friend
[rsp.Unsure.UIds.Length];
+ for (int i = 0; i < list.Unsure.Length; i++)
+ list.Unsure [i] = new Friend
(rsp.Unsure.UIds [i], this.Session);
+
+ list.Declined = new Friend
[rsp.Declined.UIds.Length];
+ for (int i = 0; i < list.Declined.Length; i ++)
+ list.Declined [i] = new Friend
(rsp.Declined.UIds [i], this.Session);
+
+ list.NotReplied = new Friend
[rsp.NotReplied.UIds.Length];
+
+ return list;
+ }
+
+ }
+ }
+}
Modified: trunk/facebook-sharp/src/Mono.Facebook/FacebookParam.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/FacebookParam.cs 2007-03-30
18:42:27 UTC (rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/FacebookParam.cs 2007-03-30
18:45:41 UTC (rev 75227)
@@ -3,6 +3,7 @@
//
// Authors:
// Thomas Van Machelen ([EMAIL PROTECTED])
+// George Talusan ([EMAIL PROTECTED])
//
// (C) Copyright 2007 Novell, Inc. (http://www.novell.com)
//
@@ -27,6 +28,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
+using System.Text;
namespace Mono.Facebook
{
@@ -35,17 +37,20 @@
private string name;
private object value;
- public string Name
- {
- get { return name; }
+ public string Name {
+ get{ return name; }
}
- public object Value
- {
- get { return value; }
+ public string Value {
+ get {
+ if (value is Array)
+ return ConvertArrayToString (value as
Array);
+ else
+ return value.ToString ();
+ }
}
- public FacebookParam (string name, object value)
+ protected FacebookParam (string name, object value)
{
this.name = name;
this.value = value;
@@ -68,5 +73,20 @@
return this.name.CompareTo ((obj as
FacebookParam).name);
}
+
+ private static string ConvertArrayToString (Array a)
+ {
+ StringBuilder builder = new StringBuilder ();
+
+ for (int i = 0; i < a.Length; i++) {
+ if (i > 0)
+ builder.Append (",");
+
+ builder.Append (a.GetValue (i).ToString ());
+ }
+
+ return builder.ToString ();
+ }
}
}
+
Modified: trunk/facebook-sharp/src/Mono.Facebook/FacebookSession.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/FacebookSession.cs 2007-03-30
18:42:27 UTC (rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/FacebookSession.cs 2007-03-30
18:45:41 UTC (rev 75227)
@@ -1,3 +1,32 @@
+//
+// Mono.Facebook.FacebookSession.cs:
+//
+// Authors:
+// Thomas Van Machelen ([EMAIL PROTECTED])
+// George Talusan ([EMAIL PROTECTED])
+//
+// (C) Copyright 2007 Novell, Inc. (http://www.novell.com)
+//
+
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
using System;
using System.Xml;
using System.Collections.Generic;
@@ -79,5 +108,161 @@
return new_album;
}
+ public Group[] GetGroups ()
+ {
+ return this.GetGroups (session_info.UId, null);
+ }
+
+ public Group[] GetGroups (long? uid, long[] gids)
+ {
+ List<FacebookParam> param_list = new
List<FacebookParam>();
+ param_list.Add (FacebookParam.Create ("session_key",
session_info.SessionKey));
+ param_list.Add (FacebookParam.Create ("call_id",
DateTime.Now.Ticks));
+ if (uid != null)
+ param_list.Add (FacebookParam.Create ("uid",
uid));
+
+ if (gids != null)
+ param_list.Add (FacebookParam.Create ("gids",
gids));
+
+ GroupsResponse rsp =
util.GetResponse<GroupsResponse>("facebook.groups.get", param_list.ToArray ());
+
+ foreach (Group gr in rsp.Groups)
+ gr.Session = this;
+
+ return rsp.Groups;
+ }
+
+ public Event[] GetEvents ()
+ {
+ return GetEvents (session_info.UId, null, 0, 0, null);
+ }
+
+ public Event[] GetEvents (long? uid, long[] eids, long
start_time, long end_time, string rsvp_status)
+ {
+ List<FacebookParam> param_list = new
List<FacebookParam>();
+ param_list.Add (FacebookParam.Create ("session_key",
session_info.SessionKey));
+ param_list.Add (FacebookParam.Create ("call_id",
DateTime.Now.Ticks));
+ if (uid != null)
+ param_list.Add (FacebookParam.Create ("uid",
uid));
+
+ if (eids != null)
+ param_list.Add (FacebookParam.Create ("eids",
eids));
+
+ param_list.Add (FacebookParam.Create ("start_time",
start_time));
+ param_list.Add (FacebookParam.Create ("end_time",
start_time));
+ if (rsvp_status != null)
+ param_list.Add (FacebookParam.Create
("rsvp_status", rsvp_status));
+
+ EventsResponse rsp =
util.GetResponse<EventsResponse>("facebook.events.get", param_list.ToArray ());
+
+ foreach (Event evt in rsp.Events)
+ evt.Session = this;
+
+ return rsp.Events;
+ }
+
+ public User GetUserInfo (long uid)
+ {
+ User[] users = this.GetUserInfo (new long[1] { uid },
User.FIELDS);
+
+ if (users.Length < 1)
+ return null;
+
+ return users[0];
+ }
+
+ public User[] GetUserInfo (long[] uids, string[] fields)
+ {
+ List<FacebookParam> param_list = new
List<FacebookParam>();
+ param_list.Add (FacebookParam.Create ("session_key",
session_info.SessionKey));
+ param_list.Add (FacebookParam.Create ("call_id",
DateTime.Now.Ticks));
+
+ if (uids == null || uids.Length == 0)
+ throw new Exception ("uid not provided");
+
+ param_list.Add (FacebookParam.Create ("uids", uids));
+ param_list.Add (FacebookParam.Create ("fields",
fields));
+
+ UserInfoResponse rsp =
util.GetResponse<UserInfoResponse>("facebook.users.getInfo", param_list.ToArray
());
+ return rsp.Users;
+ }
+
+ public Me GetLoggedInUser ()
+ {
+ return new Me (session_info.UId, this);
+ }
+
+ public Notifications GetNotifications ()
+ {
+ Notifications notifications =
util.GetResponse<Notifications>("facebook.notifications.get",
+ FacebookParam.Create ("uid", session_info.UId),
+ FacebookParam.Create ("session_key",
session_info.SessionKey),
+ FacebookParam.Create ("call_id",
DateTime.Now.Ticks));
+
+ foreach (Friend f in notifications.FriendRequests)
+ f.Session = this;
+
+ return notifications;
+ }
+
+ public Friend[] GetFriends ()
+ {
+ FriendsResponse response =
Util.GetResponse<FriendsResponse>("facebook.friends.get",
+ FacebookParam.Create ("session_key",
SessionKey),
+ FacebookParam.Create ("call_id",
DateTime.Now.Ticks));
+
+ Friend[] friends = new Friend[response.UIds.Length];
+
+ for (int i = 0; i < friends.Length; i++)
+ friends[i] = new Friend (response.UIds[i],
this);
+
+ return friends;
+ }
+
+ public bool AreFriends (Friend friend1, Friend friend2)
+ {
+ return AreFriends (friend1.UId, friend2.UId);
+ }
+
+ public bool AreFriends (long uid1, long uid2)
+ {
+ AreFriendsResponse response =
Util.GetResponse<AreFriendsResponse>("facebook.friends.areFriends",
+ FacebookParam.Create ("session_key",
SessionKey),
+ FacebookParam.Create ("call_id",
DateTime.Now.Ticks),
+ FacebookParam.Create ("uids1", uid1),
+ FacebookParam.Create ("uids2", uid2));
+
+ return response.friend_infos[0].AreFriends;
+ }
+
+ public FriendInfo[] AreFriends (long[] uids1, long[] uids2)
+ {
+ List<FacebookParam> param_list = new
List<FacebookParam> ();
+ param_list.Add (FacebookParam.Create ("session_key",
session_info.SessionKey));
+ param_list.Add (FacebookParam.Create ("call_id",
DateTime.Now.Ticks));
+
+ if (uids1 == null || uids1.Length == 0)
+ throw new Exception ("uids1 not provided");
+
+ if (uids2 == null || uids2.Length == 0)
+ throw new Exception ("uids2 not provided");
+
+ param_list.Add (FacebookParam.Create ("uids1", uids1));
+ param_list.Add (FacebookParam.Create ("uids2", uids2));
+
+ AreFriendsResponse rsp =
util.GetResponse<AreFriendsResponse> ("facebook.friends.areFriends",
param_list.ToArray ());
+ return rsp.friend_infos;
+ }
+
+ public XmlDocument Query (string sql_query)
+ {
+ XmlDocument doc = Util.GetResponse
("facebook.fql.query",
+ FacebookParam.Create ("session_key",
SessionKey),
+ FacebookParam.Create ("call_id",
DateTime.Now.Ticks),
+ FacebookParam.Create ("query", sql_query));
+
+ return doc;
+ }
}
}
+
Added: trunk/facebook-sharp/src/Mono.Facebook/Friend.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/Friend.cs 2007-03-30 18:42:27 UTC
(rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/Friend.cs 2007-03-30 18:45:41 UTC
(rev 75227)
@@ -0,0 +1,99 @@
+//
+// Mono.Facebook.Friend.cs:
+//
+// Authors:
+// George Talusan ([EMAIL PROTECTED])
+//
+
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Xml.Serialization;
+using System.Text;
+
+namespace Mono.Facebook
+{
+ public class Friend : SessionWrapper
+ {
+ [XmlElement ("uid")]
+ public long UId;
+
+ public Friend (long UId, FacebookSession session)
+ {
+ this.UId = UId;
+ this.Session = session;
+ }
+
+ public Friend ()
+ { }
+
+ public User GetUserInfo ()
+ {
+ User[] users = Session.GetUserInfo (new long[] { UId },
User.FIELDS);
+
+ return users[0];
+ }
+
+ public bool IsFriendsWith (Friend friend)
+ {
+ FriendInfo[] info = IsFriendsWith (new Friend[] {
friend });
+ return info[0].AreFriends;
+ }
+
+ public Group[] Groups
+ {
+ get { return Session.GetGroups (UId, null); }
+ }
+
+ public Event[] Events
+ {
+ get { return Session.GetEvents (UId, null, 0, 0, null);
}
+ }
+
+ public FriendInfo[] IsFriendsWith (Friend[] friends)
+ {
+ long[] me = new long[friends.Length];
+ for (int i = 0; i < me.Length; i++)
+ me[i] = UId;
+
+ long[] them = new long[friends.Length];
+ for (int i = 0; i < friends.Length; i++)
+ {
+ them[i] = friends[i].UId;
+ }
+
+ return Session.AreFriends (me, them);
+ }
+ }
+
+ public class Me : Friend
+ {
+ public Me (long uid, FacebookSession session)
+ : base (uid, session)
+ { }
+
+ public Notifications Notifications
+ {
+ get { return Session.GetNotifications (); }
+ }
+ }
+}
Added: trunk/facebook-sharp/src/Mono.Facebook/FriendInfo.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/FriendInfo.cs 2007-03-30
18:42:27 UTC (rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/FriendInfo.cs 2007-03-30
18:45:41 UTC (rev 75227)
@@ -0,0 +1,43 @@
+//
+// Mono.Facebook.FriendInfo.cs:
+//
+// Authors:
+// Thomas Van Machelen ([EMAIL PROTECTED])
+//
+
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Xml.Serialization;
+
+namespace Mono.Facebook
+{
+ public class FriendInfo
+ {
+ [XmlElement ("uid1")]
+ public int UId1;
+
+ [XmlElement ("uid2")]
+ public int UId2;
+
+ [XmlElement ("are_friends")]
+ public bool AreFriends;
+ }
+}
Added: trunk/facebook-sharp/src/Mono.Facebook/Group.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/Group.cs 2007-03-30 18:42:27 UTC
(rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/Group.cs 2007-03-30 18:45:41 UTC
(rev 75227)
@@ -0,0 +1,151 @@
+//
+// Mono.Facebook.Group.cs:
+//
+// Authors:
+// Thomas Van Machelen ([EMAIL PROTECTED])
+// George Talusan ([EMAIL PROTECTED])
+//
+// (C) Copyright 2007 Novell, Inc. (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Xml.Serialization;
+
+namespace Mono.Facebook
+{
+ public class Group : SessionWrapper
+ {
+ [XmlElement ("gid")]
+ public long GId;
+
+ [XmlElement ("name")]
+ public string Name;
+
+ [XmlElement ("nid")]
+ public int NId;
+
+ [XmlElement ("description")]
+ public string Description;
+
+ [XmlElement ("group_type")]
+ public string GroupType;
+
+ [XmlElement ("group_subtype")]
+ public string GroupSubType;
+
+ [XmlElement ("recent_news")]
+ public string RecentNews;
+
+ [XmlElement ("pic")]
+ public string pic;
+
+ [XmlIgnore ()]
+ public Uri Picture
+ {
+ get { return new Uri (pic); }
+ }
+
+ [XmlElement ("pic_big")]
+ public string pic_big;
+
+ [XmlIgnore ()]
+ public Uri PictureBig
+ {
+ get { return new Uri (pic_big); }
+ }
+
+ [XmlElement ("pic_small")]
+ public string pic_small;
+
+ [XmlIgnore ()]
+ public Uri PictureSmall
+ {
+ get { return new Uri (pic_small); }
+ }
+
+ [XmlElement ("creator")]
+ public System.Nullable<int> Creator;
+
+ [XmlElement ("update_time")]
+ public int UpdateTime;
+
+ [XmlElement ("office")]
+ public string Office;
+
+ [XmlElement ("website")]
+ public string website;
+
+ [XmlIgnore ()]
+ public Uri WebSite
+ {
+ get
+ {
+ if (website == string.Empty)
+ return null;
+
+ return new Uri (website);
+ }
+ }
+
+ [XmlElement ("venue")]
+ public Location Venue;
+
+
+ public GroupMemberList GetMembers ()
+ {
+ GroupMembersResponse rsp =
Session.Util.GetResponse<GroupMembersResponse>("facebook.groups.getMembers",
+ FacebookParam.Create ("gid", GId),
+ FacebookParam.Create ("call_id",
DateTime.Now.Ticks),
+ FacebookParam.Create ("session_key",
Session.SessionKey));
+
+ GroupMemberList members = new GroupMemberList ();
+
+ members.Members = new Friend [rsp.Members.UIds.Length];
+ for (int i = 0; i < members.Members.Length; i++)
+ members.Members [i] = new Friend
(rsp.Members.UIds [i], this.Session);
+
+ members.Admins = new Friend [rsp.Admins.UIds.Length];
+ for (int i = 0; i < members.Admins.Length; i++)
+ members.Admins [i] = new Friend
(rsp.Admins.UIds [i], this.Session);
+
+ members.NotReplied = new Friend
[rsp.NotReplied.UIds.Length];
+ for (int i = 0; i < members.NotReplied.Length; i++)
+ members.NotReplied [i] = new Friend
(rsp.NotReplied.UIds [i], this.Session);
+
+ members.Officers = new Friend
[rsp.Officers.UIds.Length];
+ for (int i = 0; i < members.Officers.Length; i++)
+ members.Officers [i] = new Friend
(rsp.Officers.UIds [i], this.Session);
+
+ return members;
+ }
+ }
+
+ public class GroupMemberList
+ {
+ public Friend[] Members;
+
+ public Friend[] Admins;
+
+ public Friend[] Officers;
+
+ public Friend[] NotReplied;
+ }
+}
Added: trunk/facebook-sharp/src/Mono.Facebook/Location.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/Location.cs 2007-03-30 18:42:27 UTC
(rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/Location.cs 2007-03-30 18:45:41 UTC
(rev 75227)
@@ -0,0 +1,51 @@
+//
+// Mono.Facebook.Location.cs:
+//
+// Authors:
+// Thomas Van Machelen ([EMAIL PROTECTED])
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Xml.Serialization;
+
+namespace Mono.Facebook
+{
+ public class Location
+ {
+ [XmlElement ("street")]
+ public string Street;
+
+ [XmlElement ("city")]
+ public string City;
+
+ [XmlElement ("state")]
+ public string State;
+
+ [XmlElement ("country")]
+ public string Country;
+
+ [XmlElement ("zip")]
+ public int Zip;
+
+ [XmlElement ("zipSpecified")]
+ public bool ZipSpecified;
+ }
+}
Added: trunk/facebook-sharp/src/Mono.Facebook/Notification.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/Notification.cs 2007-03-30
18:42:27 UTC (rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/Notification.cs 2007-03-30
18:45:41 UTC (rev 75227)
@@ -0,0 +1,59 @@
+//
+// Mono.Facebook.Notification.cs:
+//
+// Authors:
+// George Talusan ([EMAIL PROTECTED])
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Xml.Serialization;
+using System.Text;
+
+namespace Mono.Facebook
+{
+ public class Notification
+ {
+ [XmlElement ("unread")]
+ public int Unread;
+
+ [XmlElement ("most_recent")]
+ public long MostRecent;
+ }
+
+ [XmlRoot ("notifications_get_response", Namespace =
"http://api.facebook.com/1.0/", IsNullable = false)]
+ public class Notifications
+ {
+ [XmlElement ("messages")]
+ public Notification Messages;
+
+ [XmlElement ("pokes")]
+ public Notification Pokes;
+
+ [XmlElement ("shares")]
+ public Notification Shares;
+
+ [XmlElement ("friend_requests")]
+ public Friend[] FriendRequests;
+
+
+ }
+}
Added: trunk/facebook-sharp/src/Mono.Facebook/PeopleList.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/PeopleList.cs 2007-03-30
18:42:27 UTC (rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/PeopleList.cs 2007-03-30
18:45:41 UTC (rev 75227)
@@ -0,0 +1,42 @@
+//
+// Mono.Facebook.PeopleList.cs:
+//
+// Authors:
+// George Talusan ([EMAIL PROTECTED])
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Xml.Serialization;
+using System.Collections;
+
+namespace Mono.Facebook
+{
+ public class PeopleList
+ {
+ [XmlElement ("uid")]
+ public int[] uid_array;
+
+ public int[] UIds
+ {
+ get { return uid_array ?? new int[0]; }
+ }
+ }
+}
Modified: trunk/facebook-sharp/src/Mono.Facebook/Responses.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/Responses.cs 2007-03-30 18:42:27 UTC
(rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/Responses.cs 2007-03-30 18:45:41 UTC
(rev 75227)
@@ -1,3 +1,31 @@
+//
+// Mono.Facebook.Responses.cs:
+//
+// Authors:
+// Thomas Van Machelen ([EMAIL PROTECTED])
+// George Talusan ([EMAIL PROTECTED])
+//
+// (C) Copyright 2007 Novell, Inc. (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
using System;
using System.Xml.Serialization;
@@ -10,7 +38,7 @@
public string SessionKey;
[XmlElement ("uid")]
- public string UId;
+ public long UId;
[XmlElement ("secret")]
public string Secret;
@@ -62,4 +90,100 @@
[XmlAttribute ("list")]
public bool List;
}
+ [XmlRoot ("groups_get_response", Namespace =
"http://api.facebook.com/1.0/")]
+ public class GroupsResponse
+ {
+ [XmlElement ("group")]
+ public Group[] group_array;
+
+ public Group[] Groups
+ {
+ get { return group_array ?? new Group[0]; }
+ }
+
+ [XmlAttribute ("list")]
+ public bool List;
+ }
+
+ [XmlRoot ("groups_getMembers_response", Namespace =
"http://api.facebook.com/1.0/", IsNullable = false)]
+ public class GroupMembersResponse
+ {
+ [XmlElement ("members")]
+ public PeopleList Members;
+
+ [XmlElement ("admins")]
+ public PeopleList Admins;
+
+ [XmlElement ("officers")]
+ public PeopleList Officers;
+
+ [XmlElement ("not_replied")]
+ public PeopleList NotReplied;
+ }
+
+ [XmlRoot ("users_getInfo_response", Namespace =
"http://api.facebook.com/1.0/", IsNullable = false)]
+ public class UserInfoResponse
+ {
+ [XmlElement ("user")]
+ public User[] user_array;
+
+ public User[] Users
+ {
+ get { return user_array ?? new User[0]; }
+ }
+
+ [XmlAttribute ("list")]
+ public bool List;
+ }
+
+ [XmlRoot ("events_get_response",
Namespace="http://api.facebook.com/1.0/", IsNullable=false)]
+ public class EventsResponse
+ {
+ [XmlElement ("event")]
+ public Event[] event_array;
+
+ public Event[] Events
+ {
+ get { return event_array ?? new Event[0]; }
+ }
+
+ [XmlAttribute ("list")]
+ public bool List;
+ }
+
+ [XmlRoot ("events_getMembers_response", Namespace =
"http://api.facebook.com/1.0/", IsNullable = false)]
+ public class EventMembersResponse
+ {
+ [XmlElement ("attending")]
+ public PeopleList Attending;
+
+ [XmlElement ("unsure")]
+ public PeopleList Unsure;
+
+ [XmlElement ("declined")]
+ public PeopleList Declined;
+
+ [XmlElement ("not_replied")]
+ public PeopleList NotReplied;
+ }
+
+ [XmlRoot ("friends_get_response", Namespace =
"http://api.facebook.com/1.0/", IsNullable = false)]
+ public class FriendsResponse
+ {
+ [XmlElement ("uid")]
+ public int[] uids;
+
+ [XmlIgnore ()]
+ public int[] UIds
+ {
+ get { return uids ?? new int[0]; }
+ }
+ }
+
+ [XmlRoot ("friends_areFriends_response", Namespace =
"http://api.facebook.com/1.0/", IsNullable = false)]
+ public class AreFriendsResponse
+ {
+ [XmlElement ("friend_info")]
+ public FriendInfo[] friend_infos;
+ }
}
Added: trunk/facebook-sharp/src/Mono.Facebook/User.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/User.cs 2007-03-30 18:42:27 UTC
(rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/User.cs 2007-03-30 18:45:41 UTC
(rev 75227)
@@ -0,0 +1,175 @@
+//
+// Mono.Facebook.User.cs:
+//
+// Authors:
+// Thomas Van Machelen ([EMAIL PROTECTED])
+// George Talusan ([EMAIL PROTECTED])
+//
+// (C) Copyright 2007 Novell, Inc. (http://www.novell.com)
+//
+
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Xml.Serialization;
+
+namespace Mono.Facebook
+{
+ public partial class User
+ {
+ public static readonly string[] FIELDS = { "about_me",
"activities", "affiliations", "birthday", "books",
+ "current_location", "education_history", "first_name",
"hometown_location", "interests", "last_name",
+ "movies", "music", "name", "notes_count", "pic",
"pic_big", "pic_small", "political", "profile_update_time",
+ "quotes", "relationship_status", "religion", "sex",
"significant_other_id",
+ "status", "timezone", "tv", "uid", "wall_count" };
+
+ [XmlElement ("about_me")]
+ public string AboutMe;
+
+ [XmlElement ("activities")]
+ public string Activities;
+
+ [XmlElement ("birthday")]
+ public string Birthday;
+
+ [XmlElement ("books")]
+ public string Books;
+
+ [XmlElement ("current_location")]
+ public Location CurrentLocation;
+
+ [XmlElement ("first_name")]
+ public string FirstName;
+
+ [XmlElement ("hometown_location")]
+ public Location HomeTown;
+
+ [XmlElement ("interests")]
+ public string Interests;
+
+ [XmlElement ("last_name")]
+ public string LastName;
+
+ [XmlElement ("movies")]
+ public string Movies;
+
+ [XmlElement ("music")]
+ public string Music;
+
+ [XmlElement ("name")]
+ public string Name;
+
+ [XmlElement ("notes_count")]
+ public System.Nullable<int> NotesCount;
+
+ [XmlElement ("notes_countSpecified")]
+ public bool NotesCountSpecified;
+
+ [XmlElement ("pic")]
+ public string pic;
+
+ public Uri Picture
+ {
+ get
+ {
+ if (pic == string.Empty)
+ return null;
+
+ return new Uri (pic);
+ }
+ }
+
+ [XmlElement ("pic_big")]
+ public string pic_big;
+
+ public Uri PictureBig
+ {
+ get
+ {
+ if (pic_big == string.Empty)
+ return null;
+
+ return new Uri (pic_big);
+ }
+ }
+
+ [XmlElement ("pic_small")]
+ public string pic_small;
+
+ public Uri PictureSmall
+ {
+ get
+ {
+ if (pic_small == string.Empty)
+ return null;
+
+ return new Uri (pic_small);
+ }
+ }
+
+ [XmlElement ("political")]
+ public string Political;
+
+ [XmlElement ("profile_update_time")]
+ public System.Nullable<int> ProfileUpdateTime;
+
+ [XmlElement ("profile_update_timeSpecified")]
+ public bool ProfileUpdateTimeSpecified;
+
+ [XmlElement ("quotes")]
+ public string Quotes;
+
+ [XmlElement ("relationship_status")]
+ public string RelationShipStatus;
+
+ [XmlElement ("religion")]
+ public string Religion;
+
+ [XmlElement ("sex")]
+ public string Sex;
+
+ [XmlElement ("significant_other_id")]
+ public System.Nullable<int> SignificantOtherId;
+
+ [XmlElement ("significant_other_idSpecified")]
+ public bool SignificantOtherIdSpecified;
+
+ [XmlElement ("timezone")]
+ public System.Nullable<int> Timezone;
+
+ [XmlElement ("timezoneSpecified")]
+ public bool TimezonSpecified;
+
+ [XmlElement ("tv")]
+ public string TV;
+
+ [XmlElement ("uid")]
+ public int UId;
+
+ [XmlElement ("uidSpecified")]
+ public bool UIdSpecified;
+
+ [XmlElement ("wall_count")]
+ public System.Nullable<int> WallCount;
+
+ [XmlElement ("wall_countSpecified")]
+ public bool WallCountSpecified;
+ }
+}
Modified: trunk/facebook-sharp/src/Mono.Facebook/Util.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook/Util.cs 2007-03-30 18:42:27 UTC
(rev 75226)
+++ trunk/facebook-sharp/src/Mono.Facebook/Util.cs 2007-03-30 18:45:41 UTC
(rev 75227)
@@ -70,7 +70,13 @@
byte[] response_bytes = GetResponseBytes (url);
XmlSerializer response_serializer = new XmlSerializer
(typeof (T));
- return (T)response_serializer.Deserialize (new
MemoryStream (response_bytes));
+ try {
+ T response =
(T)response_serializer.Deserialize(new MemoryStream(response_bytes));
+ return response;
+ }
+ catch {
+ throw new
FacebookException(Encoding.Default.GetString(response_bytes));
+ }
}
public XmlDocument GetResponse (string method_name, params
FacebookParam[] parameters)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches