且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Facebook C#SDK上载带有标签的照片

更新时间:2022-10-31 13:30:02

要进行标记,您可以这样做(一个简单的例子):

To tag you can do that (a simple exemple):

private const string ExtendedPermissions = "user_about_me,user_photos,publish_stream";

[HttpPost]
[FacebookAuthorize(Permissions = ExtendedPermissions, LoginUrl = "/Home/LogOn?ReturnUrl=~/Home")]
public ActionResult MensagemPost(string message)
{
    var fb = new FacebookWebClient();
    dynamic me = fb.Get("me");

    string friendId_1 = // get the first one friend id
    string friendId_2 = // get the second one friend id

    var tags = new[] 
    { 
        new { tag_uid = friendId_1, x = 20, y = 20 },
        new { tag_uid = friendId_2, x = 40, y = 40 },
        new { tag_uid = (string)me.id, x = 60, y = 60 }
    };

    dynamic parameters = new ExpandoObject();
    parameters.message = message;
    parameters.tags = tags;
    parameters.url = "http://1.bp.blogspot.com/-evheT51sfeM/TlO_wZ8YDqI/AAAAAAAAA8I/fjlg0G8AgMY/s1600/The-best-top-hd-desktop-naruto-shippuden-wallpaper-naruto-shippuden-wallpapers-hd-11.jpg";

    dynamic result = fb.Post("me/photos", parameters);

    return RedirectToAction("Index", new { success = true });
}