Example #1
0
 public void DeleteAction(string actionId)
 {
     if (!string.IsNullOrEmpty(actionId))
     {
         Task.Factory.StartNew(() =>
             {
                 var client = new FacebookClient(AccessToken);
                 client.Delete(string.Format("{0}", actionId));
             });
     }
 }
Example #2
0
        public static void Delete(string accessToken, string id)
        {
            try
            {
                var fb = new FacebookClient(accessToken);

                var result = fb.Delete(id);

                // Note: This json result is not the orginal json string as returned by Facebook.
                Console.WriteLine("Json: {0}", result.ToString());
            }
            catch (FacebookApiException ex)
            {
                // Note: make sure to handle this exception.
                throw;
            }
        }
        public string LikeFBGroupPost(string postid, string accesstoken, string Isliked)
        {
            string ret = "";
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
            FacebookClient fb = new FacebookClient();
            fb.AccessToken = accesstoken;
            try
            {
                if (Isliked == "liked")
                {
                    dynamic unlike = fb.Delete("v2.0/" + postid + "/likes", null);
                    ret = "unlike";
                }
                else
                {
                    dynamic like = fb.Post("v2.0/" + postid + "/likes", null);
                    ret = "like";
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                ret = "Somthing Went Wrong";
            }

            return ret;
        }
 public string FacebookLike(String msgguid, String profileid, string msgid, string userid)
 {
     string ret = "";
     Domain.Socioboard.Domain.FacebookAccount objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(profileid, Guid.Parse(userid));
     FacebookClient fb = new FacebookClient();
     fb.AccessToken = objFacebookAccount.AccessToken;
     objFacebookMessage = objFacebookMessageRepository.GetFacebookUserWallPostDetails(Guid.Parse(msgguid));
     if (objFacebookMessage.FbLike == "likes")
     {
         System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
         var s = fb.Post("v2.0/" + msgid + "/likes", null);
         objFacebookMessage.FbLike = "unlike";
     }
     else
     {
         var s = fb.Delete(msgid + "/likes", null);
         objFacebookMessage.FbLike = "likes";
     }
     objFacebookMessageRepository.updateFacebookMessage(objFacebookMessage);
     return ret;
 }
Example #5
0
        private string SendImageWithTag(IProgress<string> progress, string filename, string inputText, List<string> uids, string albumID=null)
        {
            try
            {
                string coverImage = MyHelper.CopyFileTo(filename, FB_Image.BaseDirectory);
                string messageFile = MyHelper.CopyFileTo(inputText, FB_Image.BaseDirectory);

                //Encode
                string encodeFile = JPHideEncode(Path.GetFileName(coverImage), Path.GetFileName(messageFile));
                if (progress != null)
                    progress.Report("25|Uploading Picture");
                if (encodeFile == null)
                    return null;
                string id = Upload_Picture_Tag(Path.Combine(FB_Image.BaseDirectory, encodeFile), uids,albumID);
                if (progress != null)
                    progress.Report("50|Checking ...");
                string downloadFile = MyHelper.AppendFileName(Path.Combine(FB_Image.BaseDirectory, encodeFile), "_download");
                if (!DownloadFB(id, ActiveUser.AccessToken, downloadFile, true))
                    return null;
                //Decode
                string outputText = MyHelper.AppendFileNameNoLimit(inputText, "_ouput");
                if (outputText == null)
                    outputText = "output_test.txt";
                outputText = JPSeekDecode(Path.GetFileName(downloadFile), outputText,null,true);
                if (outputText == null)
                    return null;
                outputText = Path.Combine(FB_Image.BaseDirectory, outputText);

                //compare 2 file
                if (progress != null)
                    progress.Report("100|Finish");
                if (MyHelper.CompareOutputFile(inputText, outputText))
                {
                    return id;
                }
                else
                {
                    var fb = new FacebookClient(ActiveUser.AccessToken);
                    dynamic res = fb.Delete(id);  // xóa ảnh
                    return null;
                }

            }
            catch (Exception e)
            {
                Log(e);
                return null;
            }
        }
Example #6
0
        public static bool SetFbLike(string fBPostId, short rating, FacebookClient fbapp)
        {
            GraphCommand likeCall = null;
            if (rating <= 0)
            {
                likeCall = new GraphCommand(
                 (likeCommand) => fbapp.Delete(likeCommand, null)
                );
            }

            else if (rating > 0)
            {
                likeCall = new GraphCommand(
                 (likeCommand) => fbapp.Post(likeCommand, null)
                );
            }
            return RunLikeGraphCommand(fBPostId, likeCall);
        }
Example #7
0
 public static bool RemovePost(string fBPostId, FacebookClient fbapp)
 {
     string graphCmd = string.Format("/{0}", fBPostId);
     var response = fbapp.Delete(graphCmd);
     bool success;
     if (bool.TryParse(response.ToString(), out success))
     {
         return success;
     }
     return false;
 }
Example #8
0
        public string SendNoTestImageWithTag(IProgress<string> progress, string filename, string inputText, string albumID,List<string> uids)
        {

            try
            {
                if (String.IsNullOrEmpty(ActiveUser.AccessToken))
                    return null;

                //Reduce size ratio of picture
                if (progress != null)
                    progress.Report("15|15|Preparing Image");
                string coverImageFileName = MyHelper.CopyFileTo(filename, FB_Image.BaseDirectory);
                coverImageFileName = ProcessUserImage(coverImageFileName);
                string messageFile = MyHelper.CopyFileTo(inputText, FB_Image.BaseDirectory);

                //Encode
                if (progress != null)
                    progress.Report("50|Uploading Image");
                string encodeFile = JPHideEncode(Path.GetFileName(coverImageFileName), Path.GetFileName(inputText));
                if (string.IsNullOrEmpty(encodeFile))
                {
                    return null;
                }
                string id = Upload_Picture_Tag(Path.Combine(FB_Image.BaseDirectory, encodeFile),uids ,albumID);
                if (string.IsNullOrEmpty(id))
                {
                    return null;
                }
                if (progress != null)
                    progress.Report("75|Checking");
                string downloadFile = MyHelper.AppendFileName(Path.Combine(FB_Image.BaseDirectory, encodeFile), "_download");
                if (!DownloadFB(id, ActiveUser.AccessToken, downloadFile, true))
                    return null;


                //Decode
                string outputText = MyHelper.AppendFileNameNoLimit(inputText, "_ouput");
                if (outputText == null)
                    outputText = "output_test.txt";
                outputText = JPSeekDecode(Path.GetFileName(downloadFile), outputText,null,true);
                if (outputText == null)
                    return null;
                outputText = Path.Combine(FB_Image.BaseDirectory, outputText);

                //compare 2 file
                if (progress != null)
                    progress.Report("100|Finish");
                if (MyHelper.CompareOutputFile(inputText, outputText))
                {           
                       return coverImageFileName;
                }
                else
                {
                    var fb = new FacebookClient(ActiveUser.AccessToken);
                    dynamic res = fb.Delete(id);  // xóa ảnh
                    return null;
                }
            }
            catch (Exception e)
            {
                Log(e);
                return null;
            }
        }