在c#中上传图片到多个facebook帐户

本文关键字:facebook 帐户 | 更新日期: 2023-09-27 18:03:00

我有一个Facebook应用程序,用户可以在其中订阅。为了订阅,我制作了一个PHP网页,用户可以使用他的Facebook帐户信息登录,当他登录时,我将用户id和访问令牌存储到我的MySQL数据库中。然后我把所有的访问令牌作为XML文件到我的应用程序。

现在,我想将状态和照片发布到订阅用户的帐户。但是当我想上传照片到账户时,我必须在每次发布操作中将照片上传到每个账户,这种方法是无用的。

我的邮编如下:

public static bool PostImage(string ImageDesc, string ImagePath)
    {
        try
        {
            string accesstoken = "";
            if (ImagePath.Length < 0)
                return false;
            int progressMaxValue = Controller.participants.Descendants("participant").Count();
            int increment = 100 / progressMaxValue;
            PostImageCPanel.progressBar1.Value = 0;
            foreach (XElement xe in Controller.participants.Descendants("participant"))
            {
                try
                {
                    accesstoken = xe.Attribute("access_token").Value;
                    FacebookClient client = new FacebookClient(accesstoken); 
                    var imageStream = File.OpenRead(ImagePath);

                    dynamic res = client.Post("/me/photos", new
                    {
                        message = (ImageDesc"),
                        file = new FacebookMediaStream
                        {
                            ContentType = "image/jpg",
                            FileName = Path.GetFileName(ImagePath)
                        }.SetValue(imageStream)
                    });
                    PostImageCPanel.progressBar1.Value += increment;
                }
                catch (FacebookOAuthException ex)
                {
                    MessageBox.Show(ex);
                }                     
            }

所以,我问我是否可以上传照片到MySQL数据库只有一次,然后将其发布到参与者的Facebook帐户,而不是每次为每个帐户上传。或者另一种更快发布照片的方法

在c#中上传图片到多个facebook帐户

是的,你可以,我刚刚测试了它2天前和工作良好的我与CronJobs。对于你来说,这也需要一些时间,因为每次你发布照片,facebook都会重新上传。