Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1.     public class Subscriber : ModelBase, ISubscriber
  2.     {
  3.         public string id { get; set; }
  4.  
  5.         public Boolean IsFan(string objectId, FacebookClient client)
  6.         {
  7.             dynamic result = client.Get(String.Format("/{0}/likes", id));
  8.             this.LogInfo(String.Format("Checking, whether {0} likes {1}", id, objectId));
  9.  
  10.             try
  11.             {
  12.                 if (Enumerable.Count(result.data) > 0)
  13.                 {
  14.                     foreach (dynamic item in result.data)
  15.                     {
  16.                         if (item.id == objectId)
  17.                         {
  18.                             this.LogInfo(String.Format("{0} likes {1}", id, item.id));
  19.                             return true;
  20.                         }
  21.  
  22.                         this.LogDebug(String.Format("{0} likes {1}", id, item.id));
  23.                     }
  24.                 }
  25.                 else
  26.                 {
  27.                     this.LogError("Error while getting likes for subscriber {0}. There seem to be no likes. Facebook query result was:");
  28.                     this.LogError(result.ToString());
  29.                     return true;
  30.                 }
  31.             }
  32.             catch (Exception ex)
  33.             {
  34.                 this.LogError("Error while getting likes for subscriber {0}. Facebook query result was:");
  35.                 this.LogError(result.ToString());
  36.                 this.LogError("Error was:");
  37.                 this.LogError(ex.ToString());
  38.                 return true;
  39.             }
  40.  
  41.             return false;
  42.         }
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement