代码之家  ›  专栏  ›  技术社区  ›  TruMan1

使用Facebook图形API发布为链接类型

  •  7
  • TruMan1  · 技术社区  · 14 年前

    我正在使用Facebook图形API在用户墙上发布。我给它这些参数:

    message
    name
    description
    picture
    link
    caption
    

    它贴在墙上,但并不是把它当作一个链接。我知道这一点是因为它不会在点击链接时打开一个新的标签,也没有共享操作链接,Twitter也不会接收它,因为我只让它通过链接过滤我的墙。

    我看到facebook文档有两个单独的文档页面用于发布“post”和“link”对象。但是链接发布到相同的图表路径,因此我不确定如何支持它工作:

    http://developers.facebook.com/docs/reference/api/post

    http://developers.facebook.com/docs/reference/api/link

    有人能用这个吗?

    2 回复  |  直到 12 年前
        1
  •  2
  •   pascalhein    12 年前

    使用codeplex.com上提供的facebook api并尝试一下,

    Facebook.Rest.attachment_media_image image1 = new attachment_media_image();
    
    image1.href = "";
    image1.src = "";
    
    Facebook.Rest.attachment a = new Facebook.Rest.attachment();
    a.media = new List<Facebook.Rest.attachment_media> { image1 };
    a.href = "";
    a.name = "";
    a.caption = "{*actor*}";
    a.properties = null;
    
    if(fbapi.Users.HasAppPermission(Enums.ExtendedPermissions.publish_stream))
        fbapi.Stream.Publish(" Your message", a,
                             new List<action_link>()
                             {
                                 new action_link() 
                                 {
                                     text = "",                                      
                                     href = ""
                                 } 
                             },
                             null, 0);
    
        2
  •  0
  •   sakibmoon    12 年前

    使用打开的图形时,我要做的是:

    var uri = new Uri(
        "https://graph.facebook.com/me/links?access_token=" + AccessToken);
    
    var data =
        message != null
            ? string.Format(
                "link={0}&message={1}",
                Uri.EscapeDataString(link),
                Uri.EscapeDataString(message))
            : string.Format("link={0}", Uri.EscapeDataString(link));
    
    // (parameters other than link and message are grabbed from a website anyway)
    
    WebClient client = new WebClient();
    client.Headers["Content-type"] = "application/x-www-form-urlencoded";
    client.Encoding = Encoding.UTF8;
    client.UploadStringAsync(uri, "POST", data);