【问题标题】:Tag a photo on facebook with C#?用 C# 在 Facebook 上标记照片?
【发布时间】:2012-04-01 00:05:45
【问题描述】:

在 sdk 上标记照片是否存在错误?因为我读了一些东西,有些人有同样的问题......而且它是新的......

无论如何.. 我可以在 android 上标记照片并且它可以工作.. 现在我正在尝试在 c# 上标记照片但我遇到了一些错误.. 现在是“无效的照片标记主题”

这是我的 C# 代码

        PhotoTag tags = new PhotoTag { tag_uid = "?????", x = "10", y = "10", tag_text ="heyy.."};
        List<PhotoTag> tagList = new List<PhotoTag>() { tags };
        var tagparameters =  JsonConvert.SerializeObject(tagList);
        var photoDetails = new Dictionary<string, object>();

        photoDetails.Add("tags", tagparameters);
        var fbResult = client.Post("/" + photoID+  "/tags", photoDetails);

//*************************************************** ******************

public class PhotoTag
{
    public string tag_uid  { get; set; }
    public string tag_text { get; set; }
    public string x { get; set; }
    public string y { get; set; }
}

我在这里阅读https://developers.facebook.com/docs/reference/api/photo/

我使用了 'to' 和 'id' 而不是 'tag_uid' 但我又遇到了另一个错误。(这就像它不是一个有效的参数)

这里是参数的输出

[0] = {[tags, [{"tag_uid":"641194276","tag_text":"heyy..","x":"10","y":"10"}]]}

这是我的 android 代码,它可以工作..

post a photo to friend's wall on facebook with android

好吧..我有两个问题

1- 我的 C# 代码中的错误在哪里?

2- 如何标记多个朋友??

在sdk页面上,有PHOTO_ID/tags?tags=[{"id":"1234"}, {"id":"12345"}]
但正如我解释的那样,它不起作用......

谢谢

【问题讨论】:

    标签: c# facebook tagging


    【解决方案1】:

    我的代码在这里工作:

    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 });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多