PageRenderTime 37ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/Source/facebook.Linq/Web/Facebook.cs

https://bitbucket.org/assaframan/facebooklinq
C# | 76 lines | 59 code | 9 blank | 8 comment | 2 complexity | 73ddca39bdfd4d7e96e3d4618bc00eaa MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Configuration;
  6. using System.Text;
  7. using System.Globalization;
  8. using System.Net;
  9. using System.IO;
  10. using System.Security.Cryptography;
  11. using System.Xml.Serialization;
  12. using System.Diagnostics;
  13. namespace facebook.Web
  14. {
  15. //[Remotable]
  16. class Facebook
  17. {
  18. static FacebookConfiguration Configuration;
  19. static Facebook()
  20. {
  21. Configuration = FacebookConfiguration.Current;
  22. APIKey = Configuration.APIKey;
  23. Secret = Configuration.Secret;
  24. ApplicationID = Configuration.ApplicationID;
  25. DefaultPage = Configuration.DefaultPage;
  26. }
  27. public static bool HasValidConfiguration
  28. {
  29. get
  30. {
  31. return APIKey.IsNotNullOrEmpty() && ApplicationID.IsNotNullOrEmpty() && Secret.IsNotNullOrEmpty();
  32. }
  33. }
  34. internal static string APIKey { get; set; }
  35. public static string DefaultPage { get; set; }
  36. //[Remotable(false)]
  37. internal static string Secret { get; set; }
  38. internal static string ApplicationID { get; set; }
  39. public static bool IsSessionAuthenticated
  40. {
  41. get
  42. {
  43. return FacebookSession.Current.IsAuthenticated;
  44. }
  45. }
  46. private static string FACEBOOK_LOGIN_URL = @"http://www.facebook.com/login.php?api_key=";
  47. private static string FACEBOOK_CANVAS_PARAM = "&canvas";
  48. private static string FACEBOOK_VERSION_PARAM = "&v=1.0";
  49. public static string FacebookLoginUrl
  50. {
  51. get
  52. {
  53. return FACEBOOK_LOGIN_URL + APIKey + FACEBOOK_CANVAS_PARAM + FACEBOOK_VERSION_PARAM;;
  54. }
  55. }
  56. /// <summary>
  57. /// When an application requires a certain (new) permission, it needs to redirect the user to the URL provided by this method. After confirmation, HasApplicationPermission may be called again.
  58. /// </summary>
  59. /// <param name="perm"></param>
  60. /// <returns></returns>
  61. public string GetGrantAccessUrl(facebook.Types.Enums.Extended_Permissions perm)
  62. {
  63. //TODO: check for permission
  64. return "http://www.facebook.com/authorize.php?api_key=" + APIKey + "&v=1.0&ext_perm=" + perm.ToString();
  65. }
  66. }
  67. }