Author: rtyler
Date: 2007-11-08 04:37:59 -0500 (Thu, 08 Nov 2007)
New Revision: 89180

Added:
   trunk/facebook-sharp/src/Mono.Facebook.Platform/Auth.cs
   trunk/facebook-sharp/src/Mono.Facebook.Platform/NOTES
   trunk/facebook-sharp/src/Mono.Facebook.Platform/Responses/AuthSession.cs
Modified:
   trunk/facebook-sharp/examples/WeatherSharp/Default.aspx.cs
   trunk/facebook-sharp/examples/WeatherSharp/bin/Mono.Facebook.Platform.dll
   trunk/facebook-sharp/examples/WeatherSharp/bin/WeatherSharp.dll
   trunk/facebook-sharp/src/Mono.Facebook.Platform/FBML.cs
   trunk/facebook-sharp/src/Mono.Facebook.Platform/FQL.cs
   trunk/facebook-sharp/src/Mono.Facebook.Platform/Facebook.cs
   trunk/facebook-sharp/src/Mono.Facebook.Platform/Feed.cs
   trunk/facebook-sharp/src/Mono.Facebook.Platform/Notifications.cs
   trunk/facebook-sharp/src/Mono.Facebook.Platform/Profile.cs
   trunk/facebook-sharp/src/Mono.Facebook.Platform/Responses/User.cs
   trunk/facebook-sharp/src/Mono.Facebook.Platform/Users.cs
Log:
Polish off some more Facebook API calls
 * auth.getSession
 * profile.setFBML
 * profile.getFBML

"Optimization" such that we're only creating on JavaScriptSerializer for the 
entire lifetime of the assembly, instead of per-call (duh)

Update Weather# to use some of the methods


Modified: trunk/facebook-sharp/examples/WeatherSharp/Default.aspx.cs
===================================================================
--- trunk/facebook-sharp/examples/WeatherSharp/Default.aspx.cs  2007-11-08 
09:29:39 UTC (rev 89179)
+++ trunk/facebook-sharp/examples/WeatherSharp/Default.aspx.cs  2007-11-08 
09:37:59 UTC (rev 89180)
@@ -40,6 +40,9 @@
                        User user = Users.GetInfo(new string[] {"name", 
"current_location", "affiliations"});
 
                        //Console.WriteLine(FQL.Query(String.Format("SELECT 
name, affiliations FROM user WHERE uid = {0}", fb_uid)));
+                       
+                       Profile.SetFbml(String.Format("<strong>Last updated the 
profile at {0}</strong>", DateTime.Now));
+                       Notifications.Get();
 
                        LoadWeatherData(user);
 

Modified: 
trunk/facebook-sharp/examples/WeatherSharp/bin/Mono.Facebook.Platform.dll
===================================================================
(Binary files differ)

Modified: trunk/facebook-sharp/examples/WeatherSharp/bin/WeatherSharp.dll
===================================================================
(Binary files differ)

Added: trunk/facebook-sharp/src/Mono.Facebook.Platform/Auth.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook.Platform/Auth.cs     2007-11-08 
09:29:39 UTC (rev 89179)
+++ trunk/facebook-sharp/src/Mono.Facebook.Platform/Auth.cs     2007-11-08 
09:37:59 UTC (rev 89180)
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+
+namespace Mono.Facebook.Platform
+{
+       public class Auth
+       {
+               #region "Public Static Methods (Facebook)"
+               public static AuthSession GetSession(string auth_token)
+               {
+                       Dictionary<string, string> parameters = new 
Dictionary<string, string>();
+                       parameters.Add("auth_token", auth_token);
+
+                       string response = 
Facebook.Instance.MakeRequest("auth.getSession", parameters);
+
+                       if (Facebook.Instance.Format == ResponseType.Json)
+                       {
+                               return 
Facebook.Instance.Serializer.Deserialize<AuthSession>(response);
+                       }
+
+            throw new NotImplementedException("Looks like that call isn't 
supported yet");
+               }
+               #endregion
+       }
+}
+

Modified: trunk/facebook-sharp/src/Mono.Facebook.Platform/FBML.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook.Platform/FBML.cs     2007-11-08 
09:29:39 UTC (rev 89179)
+++ trunk/facebook-sharp/src/Mono.Facebook.Platform/FBML.cs     2007-11-08 
09:37:59 UTC (rev 89180)
@@ -4,13 +4,7 @@
 {
     public class FBML
     {
-        #region "Member Variables"
+               #region "Public Static Methods (Facebook)"
         #endregion
-
-        #region "Constructors"
-        public FBML()
-        {
-        }
-        #endregion
     }
 }

Modified: trunk/facebook-sharp/src/Mono.Facebook.Platform/FQL.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook.Platform/FQL.cs      2007-11-08 
09:29:39 UTC (rev 89179)
+++ trunk/facebook-sharp/src/Mono.Facebook.Platform/FQL.cs      2007-11-08 
09:37:59 UTC (rev 89180)
@@ -21,8 +21,7 @@
             {
                                if (typeof(T) == typeof(string))
                                        return 
(T)Activator.CreateInstance(typeof(T), response.ToCharArray());
-                JavaScriptSerializer serializer = new JavaScriptSerializer();
-                               return serializer.Deserialize<T>(response);
+                               return 
Facebook.Instance.Serializer.Deserialize<T>(response);
             }
 
             throw new NotImplementedException("Looks like that call isn't 
supported yet");

Modified: trunk/facebook-sharp/src/Mono.Facebook.Platform/Facebook.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook.Platform/Facebook.cs 2007-11-08 
09:29:39 UTC (rev 89179)
+++ trunk/facebook-sharp/src/Mono.Facebook.Platform/Facebook.cs 2007-11-08 
09:37:59 UTC (rev 89180)
@@ -5,6 +5,7 @@
 using System.Security.Cryptography;
 using System.Text;
 using System.Web;
+using System.Web.Script.Serialization;
 using System.Web.UI;
 
 namespace Mono.Facebook.Platform
@@ -23,6 +24,7 @@
         private UserSession _session;
         private string _response_type = "JSON";
         private string _server_url = _unsecure_server_url;
+               private JavaScriptSerializer _serializer = null;
 
         private Notifications _notifications = null;
         private FQL _fql = null;
@@ -53,6 +55,10 @@
         {
             get { return _session; }
         }
+               public JavaScriptSerializer Serializer
+               {
+                       get { return _serializer; }
+               }
         public string ApiKey
         {
             get { return _api_key; }
@@ -200,6 +206,7 @@
         #region "Constructors"
         private Facebook()
         {
+                       _serializer = new JavaScriptSerializer();
         }
         #endregion
 

Modified: trunk/facebook-sharp/src/Mono.Facebook.Platform/Feed.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook.Platform/Feed.cs     2007-11-08 
09:29:39 UTC (rev 89179)
+++ trunk/facebook-sharp/src/Mono.Facebook.Platform/Feed.cs     2007-11-08 
09:37:59 UTC (rev 89180)
@@ -5,63 +5,63 @@
 {
     public class Feed
     {
-       #region "Public Static Methods (Facebook)"
-       public static bool PublishActionOfUser(string title)
-       {
-               return Feed.PublishActionOfUser(title, string.Empty);
-       }
-       public static bool PublishActionOfUser(string title, string body)
-       {
-               return Feed.PublishActionOfUser(title, body, string.Empty, 
string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, 
string.Empty, string.Empty);
-       }
-       public static bool PublishActionOfUser(string title, string body, 
string image_1, string image_1_link)
-       {
-               return Feed.PublishActionOfUser(title, body, image_1, 
image_1_link, string.Empty, string.Empty, string.Empty, string.Empty, 
string.Empty, string.Empty);
-       }
-       public static bool PublisActionOfUser(string title, string body, string 
image_1, string image_1_link, string image_2, string image_2_link)
-       {
-               return Feed.PublishActionOfUser(title, body, image_1, 
image_1_link, image_2, image_2_link, string.Empty, string.Empty, string.Empty, 
string.Empty);
-       }
-       public static bool PublishActionOfUser(string title, string body, 
string image_1, string image_1_link, string image_2, string image_2_link, 
string image_3, string image_3_link)
-       {
-               return Feed.PublishActionOfUser(title, body, image_1, 
image_1_link, image_2, image_2_link, image_3, image_3_link, string.Empty, 
string.Empty);
-       }
-       public static bool PublishActionOfUser(string title, string body, 
string image_1, string image_1_link, string image_2, string image_2_link, 
string image_3, string image_3_link, string image_4, string image_4_link)
-       {
-               return Feed.PublishBasicFeedItem("publishActionOfUser", title, 
body, image_1, image_1_link, image_2, image_2_link, image_3, image_3_link, 
image_4, image_4_link, -1);
-       }
+               #region "Public Static Methods (Facebook)"
+               public static bool PublishActionOfUser(string title)
+               {
+                       return Feed.PublishActionOfUser(title, string.Empty);
+               }
+               public static bool PublishActionOfUser(string title, string 
body)
+               {
+                       return Feed.PublishActionOfUser(title, body, 
string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, 
string.Empty, string.Empty, string.Empty);
+               }
+               public static bool PublishActionOfUser(string title, string 
body, string image_1, string image_1_link)
+               {
+                       return Feed.PublishActionOfUser(title, body, image_1, 
image_1_link, string.Empty, string.Empty, string.Empty, string.Empty, 
string.Empty, string.Empty);
+               }
+               public static bool PublisActionOfUser(string title, string 
body, string image_1, string image_1_link, string image_2, string image_2_link)
+               {
+                       return Feed.PublishActionOfUser(title, body, image_1, 
image_1_link, image_2, image_2_link, string.Empty, string.Empty, string.Empty, 
string.Empty);
+               }
+               public static bool PublishActionOfUser(string title, string 
body, string image_1, string image_1_link, string image_2, string image_2_link, 
string image_3, string image_3_link)
+               {
+                       return Feed.PublishActionOfUser(title, body, image_1, 
image_1_link, image_2, image_2_link, image_3, image_3_link, string.Empty, 
string.Empty);
+               }
+               public static bool PublishActionOfUser(string title, string 
body, string image_1, string image_1_link, string image_2, string image_2_link, 
string image_3, string image_3_link, string image_4, string image_4_link)
+               {
+                       return Feed.PublishBasicFeedItem("publishActionOfUser", 
title, body, image_1, image_1_link, image_2, image_2_link, image_3, 
image_3_link, image_4, image_4_link, -1);
+               }
 
-       public static bool PublishStoryToUser(string title, string body, string 
image_1, string image_1_link, string image_2, string image_2_link, string 
image_3, string image_3_link, string image_4, string image_4_link, int priority)
-       {
-               return Feed.PublishBasicFeedItem("publishStoryToUser", title, 
body, image_1, image_1_link, image_2, image_2_link, image_3, image_3_link, 
image_4, image_4_link, priority);
-       }
+               public static bool PublishStoryToUser(string title, string 
body, string image_1, string image_1_link, string image_2, string image_2_link, 
string image_3, string image_3_link, string image_4, string image_4_link, int 
priority)
+               {
+                       return Feed.PublishBasicFeedItem("publishStoryToUser", 
title, body, image_1, image_1_link, image_2, image_2_link, image_3, 
image_3_link, image_4, image_4_link, priority);
+               }
 
-       public static bool PublishBasicFeedItem(string itemType, string title, 
string body, string image_1, string image_1_link, string image_2, string 
image_2_link, string image_3, string image_3_link, string image_4, string 
image_4_link, int priority)
-       {
-               Dictionary<string, string> parameters = new Dictionary<string, 
string>();
-               parameters.Add("title", title);
-               parameters.Add("body", body);
-               parameters.Add("image_1", image_1);
-               parameters.Add("image_1_link", image_1_link);
-               parameters.Add("image_2", image_2);
-               parameters.Add("image_2_link", image_2_link);
-               parameters.Add("image_3", image_3);
-               parameters.Add("image_3_link", image_3_link);
-               parameters.Add("image_4", image_4);
-               parameters.Add("image_4_link", image_4_link);
-               if (priority > 0)
-                       parameters.Add("priority", priority.ToString());
+               public static bool PublishBasicFeedItem(string itemType, string 
title, string body, string image_1, string image_1_link, string image_2, string 
image_2_link, string image_3, string image_3_link, string image_4, string 
image_4_link, int priority)
+               {
+                       Dictionary<string, string> parameters = new 
Dictionary<string, string>();
+                       parameters.Add("title", title);
+                       parameters.Add("body", body);
+                       parameters.Add("image_1", image_1);
+                       parameters.Add("image_1_link", image_1_link);
+                       parameters.Add("image_2", image_2);
+                       parameters.Add("image_2_link", image_2_link);
+                       parameters.Add("image_3", image_3);
+                       parameters.Add("image_3_link", image_3_link);
+                       parameters.Add("image_4", image_4);
+                       parameters.Add("image_4_link", image_4_link);
+                       if (priority > 0)
+                               parameters.Add("priority", priority.ToString());
 
-               string response = 
Facebook.Instance.MakeRequest(String.Format("feed.{0}", itemType), paramaters);
+                       string response = 
Facebook.Instance.MakeRequest(String.Format("feed.{0}", itemType), parameters);
 
-               if (Facebook.Instance.Format == ResponseType.Json)
-               {
-                       Console.WriteLine("Response: {0}{1}", 
Environment.NewLine, response);
-                       return true;
+                       if (Facebook.Instance.Format == ResponseType.Json)
+                       {
+                               Console.WriteLine("Response: {0}{1}", 
Environment.NewLine, response);
+                               return true;
+                       }
+
+                       throw new NotImplementedException("Looks like that call 
isn't supported yet!");
                }
-               
-               throw new NotImplementedException("Looks like that call isn't 
supported yet!");
+               #endregion      
        }
-       #endregion      
-    }
 }

Added: trunk/facebook-sharp/src/Mono.Facebook.Platform/NOTES
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook.Platform/NOTES       2007-11-08 
09:29:39 UTC (rev 89179)
+++ trunk/facebook-sharp/src/Mono.Facebook.Platform/NOTES       2007-11-08 
09:37:59 UTC (rev 89180)
@@ -0,0 +1,59 @@
+Currently Mono.Facebook.Platform is still incomplete, here's a list of the 
entirety of Facebook's platform API calls
+and what's been implemented thus far versus what's left.
+
+There's not a lot of error checking as of now in Mono.Facebook.Platform 
(2007.11.07) but as soon as the majority of 
+the "core" API calls are supported in JSON, more robust error handling will be 
added 
+
+Formats:
+--------------
+       [ ] - XML
+       [o] - JSON
+
+
+API Calls:
+--------------
+Key: 
+       [o] = complete
+       [j] = JSON-only
+       [x] = XML-only
+--------------
+       [j] - auth.getSession
+       [ ] - events.get
+       [ ] - events.getMembers
+       [ ] - fbml.refreshImgSrc
+       [ ] - fbml.refreshRefUrl
+       [ ] - fbml.setRefHandle
+       [j] - feed.publishStoryToUser
+       [j] - feed.publishActionOfUser
+       [ ] - feed.publishTemplatizedAction
+       [j] - fql.query
+       [ ] - friends.areFriends
+       [ ] - friends.get
+       [ ] - friends.getAppUsers
+       [ ] - groups.get
+       [ ] - groups.getMembers
+       [ ] - marketplace.createListing
+       [ ] - marketplace.getCategories
+       [ ] - marketplace.getListings
+       [ ] - marketplace.getSubCategories
+       [ ] - marketplace.removeListing
+       [ ] - marketplace.search
+       [ ] - notifications.get
+       [ ] - notifications.send
+       [ ] - photos.addTag
+       [ ] - photos.createAlbum
+       [ ] - photos.get
+       [ ] - photos.getAlbums
+       [ ] - photos.getTags
+       [ ] - photos.upload
+       [j] - profile.setFBML
+       [j] - profile.getFBML
+       [j] - users.getInfo
+       [j] - users.getLoggedInUser
+       [j] - users.hasAppPermission
+       [j] - users.isAppAdded
+       [ ] - users.setStatus
+       [ ] - pages.isAppAdded
+       [ ] - pages.isAdmin
+       [ ] - pages.isFan
+       [ ] - pages.getInfo

Modified: trunk/facebook-sharp/src/Mono.Facebook.Platform/Notifications.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook.Platform/Notifications.cs    
2007-11-08 09:29:39 UTC (rev 89179)
+++ trunk/facebook-sharp/src/Mono.Facebook.Platform/Notifications.cs    
2007-11-08 09:37:59 UTC (rev 89180)
@@ -1,16 +1,22 @@
 using System;
+using System.Collections.Generic;
 
 namespace Mono.Facebook.Platform
 {
     public class Notifications
     {
-        #region "Member Variables"
-        #endregion
+               #region "Public Static Methods (Facebook)"
+               public static void Get()
+               {
+                       string response = 
Facebook.Instance.MakeRequest("notifications.get");
 
-        #region "Constructors"
-        public Notifications()
-        {
+            if (Facebook.Instance.Format == ResponseType.Json)
+            {
+                               Console.WriteLine(response);
+            }
+
+            throw new NotImplementedException("Looks like that call isn't 
supported yet");
         }
-        #endregion
+               #endregion
     }
 }

Modified: trunk/facebook-sharp/src/Mono.Facebook.Platform/Profile.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook.Platform/Profile.cs  2007-11-08 
09:29:39 UTC (rev 89179)
+++ trunk/facebook-sharp/src/Mono.Facebook.Platform/Profile.cs  2007-11-08 
09:37:59 UTC (rev 89180)
@@ -1,16 +1,52 @@
 using System;
+using System.Collections.Generic;
 
 namespace Mono.Facebook.Platform
 {
     public class Profile
     {
-        #region "Member Variables"
-        #endregion
+               #region "Public Static Methods (Facebook)"
+               public static bool SetFbml(string markup)
+               {
+                       return Profile.SetFbml(markup, -1);
+               }
+               public static bool SetFbml(string markup, Int64 uid)
+               {
+                       Dictionary<string, string> parameters = new 
Dictionary<string, string>();
 
-        #region "Constructors"
-        public Profile()
-        {
-        }
+                       parameters.Add("markup", markup);
+                       if (uid > 0)
+                               parameters.Add("uid", uid.ToString());
+
+                       string response = 
Facebook.Instance.MakeRequest("profile.setFBML", parameters);
+
+                       if (Facebook.Instance.Format == ResponseType.Json)
+                       {
+                               return 
Facebook.Instance.Serializer.Deserialize<bool>(response);
+                       }
+
+            throw new NotImplementedException("Looks like that call isn't 
supported yet");
+               }
+
+               public static string GetFbml()
+               {
+                       return Profile.GetFbml(-1);
+               }
+               public static string GetFbml(Int64 uid)
+               {
+                       Dictionary<string, string> parameters = new 
Dictionary<string, string>();
+                       if (uid > 9)
+                               parameters.Add("uid", uid.ToString());
+
+                       string response = 
Facebook.Instance.MakeRequest("profile.getFBML", parameters);
+                       
+                       if (Facebook.Instance.Format == ResponseType.Json)
+                       {
+                               return 
Facebook.Instance.Serializer.Deserialize<String>(response);
+                       }
+
+            throw new NotImplementedException("Looks like that call isn't 
supported yet");
+               }
         #endregion
     }
 }

Added: trunk/facebook-sharp/src/Mono.Facebook.Platform/Responses/AuthSession.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook.Platform/Responses/AuthSession.cs    
2007-11-08 09:29:39 UTC (rev 89179)
+++ trunk/facebook-sharp/src/Mono.Facebook.Platform/Responses/AuthSession.cs    
2007-11-08 09:37:59 UTC (rev 89180)
@@ -0,0 +1,13 @@
+using System;
+
+namespace Mono.Facebook.Platform
+{
+       public class AuthSession
+       {
+        #region "Member Variables"
+               public string uid;
+               public string session_key;
+               public DateTime expires;
+        #endregion
+    }
+}

Modified: trunk/facebook-sharp/src/Mono.Facebook.Platform/Responses/User.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook.Platform/Responses/User.cs   
2007-11-08 09:29:39 UTC (rev 89179)
+++ trunk/facebook-sharp/src/Mono.Facebook.Platform/Responses/User.cs   
2007-11-08 09:37:59 UTC (rev 89180)
@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Web.Script.Serialization;
 
 namespace Mono.Facebook.Platform
 {

Modified: trunk/facebook-sharp/src/Mono.Facebook.Platform/Users.cs
===================================================================
--- trunk/facebook-sharp/src/Mono.Facebook.Platform/Users.cs    2007-11-08 
09:29:39 UTC (rev 89179)
+++ trunk/facebook-sharp/src/Mono.Facebook.Platform/Users.cs    2007-11-08 
09:37:59 UTC (rev 89180)
@@ -22,13 +22,27 @@
             
             if (Facebook.Instance.Format == ResponseType.Json)
             {
-                JavaScriptSerializer serializer = new JavaScriptSerializer();
-                return serializer.Deserialize<bool>(response);
+                               return 
Facebook.Instance.Serializer.Deserialize<bool>(response);
             }
 
             throw new NotImplementedException("Looks like that call isn't 
supported yet");
         }
 
+        public static bool HasAppPermission(string ext_perm)
+        {
+                       Dictionary<string, string> parameters = new 
Dictionary<string, string>();
+                       parameters.Add("ext_perm", ext_perm);
+
+                       string response = 
Facebook.Instance.MakeRequest("users.hasAppPermission", parameters);
+            
+            if (Facebook.Instance.Format == ResponseType.Json)
+            {
+                               return 
Facebook.Instance.Serializer.Deserialize<bool>(response);
+            }
+
+            throw new NotImplementedException("Looks like that call isn't 
supported yet");
+               }
+
         public static User GetInfo()
         {
                        return GetInfo(DefaultFields);
@@ -59,8 +73,7 @@
 
             if (Facebook.Instance.Format == ResponseType.Json)
             {
-                JavaScriptSerializer serializer = new JavaScriptSerializer();
-                return serializer.Deserialize<List<User>>(response);
+                               return 
Facebook.Instance.Serializer.Deserialize<List<User>>(response);
             }
 
             throw new NotImplementedException("Looks like that call isn't 
supported yet");
@@ -72,8 +85,7 @@
 
             if (Facebook.Instance.Format == ResponseType.Json)
             {
-                JavaScriptSerializer serializer = new JavaScriptSerializer();
-                return serializer.Deserialize<Int64>(response);
+                               return 
Facebook.Instance.Serializer.Deserialize<Int64>(response);
             }
 
             throw new NotImplementedException("Looks like that call isn't 
supported yet");

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to