I am using Facebook Sdk C# To develop a desktop program for publication posts in Facebook groups. The software will publish only to 5 groups , if possible to any correct my problem
this Method i use
My separate Class File
public static string UploadPost(string groupid, string intTitle, string inMessage, string inLinkCaption, string inLinkUrl = "", string inLinkDescription = "", string inLinkUrlPicture = "")
{
object obj;
Facebook.JsonObject jsonObj;
FacebookClient client;
string access_token = AppSettings.Default.AccessToken.ToString();
client = new FacebookClient(access_token);
var args = new Dictionary<string, object>();
args["message"] = inMessage;
args["caption"] = inLinkCaption;
args["description"] = inLinkDescription;
args["name"] = intTitle;
args["picture"] = inLinkUrlPicture;
args["link"] = inLinkUrl;
if ((obj = client.Post("/" + groupid + "/feed", args)) != null)
{
if ((jsonObj = obj as Facebook.JsonObject) != null)
{
if (jsonObj.Count > 1)
return jsonObj[1].ToString();
}
}
return string.Empty;
}
internal static bool UploadPost(string p1, string p2)
{
throw new NotImplementedException();
}
public static string link { get; set; }
}
}
And this my Post Button
private void btnPost_Click(object sender, EventArgs e)
{
if (IsLogin != true)
{
bntLogin.Hide();
btnLogout.Show();
frmLogin frm = new frmLogin();
frm.ShowDialog();
System.Threading.Thread.Sleep(15000);
for (int i = 0; i < lstgroups.Items.Count; i++)
{
//هنا الفاصل الزمني
System.Threading.Thread.Sleep(15000);
// هنا كود الفصل
if (Class1.UploadPost(lstgroupsbox.Items[i].ToString(),"", txtStatus.Text,"", txtLink.Text,"", txtImagePath.Text) == string.Empety)
lblshow.Text = "Sent To " + lstgroups.Items[i].Text;
{
//foreach (var item in lstgroups.Items)
//{
// if (Class1.UploadPost(item.ToString(), "", txtStatus.Text, "", 2, "", txtImagePath.Text) != string.Empty)
// MessageBox.Show("Post Has Been Sent");
//}
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire