【问题标题】:How to include html in stream.Publish如何在 stream.Publish 中包含 html
【发布时间】:2010-07-02 10:01:17
【问题描述】:

我正在使用旧的 Rest API(和旧的 Javascript SDK)在 facebook 中开发 iframe 应用程序。

但是,我希望墙上的帖子(调用 stream.Publish)包含新行,并让人们的姓名带有指向他们个人资料的链接。但是,每次我包含 html 内容时,FB 都会将其剥离。但我知道这是可以做到的,因为有些应用程序会这样做,例如:

http://img.skitch.com/20100702-jhqradpi3td4d53sdb3qin92sb.png

干杯, 泽

【问题讨论】:

    标签: facebook publish


    【解决方案1】:

    墙帖中不能包含任意 HTML。如果它看起来像 HTML,Facebook 会删除它。我认为 Facebook 唯一会做的其他更改是将看起来像链接的文本转换为链接(因此,如果您在消息中的某处有 http://www.google.com,Facebook 会自动将其转换为链接)。

    不过,Facebook 确实提供了一些基本功能,可以通过 stream.publish 通过传入其他参数来包含图片、标题、描述、链接等基本内容。这是一个包含 Facebook 文档 (http://wiki.developers.facebook.com/index.php/Stream.publish) 中的一些内容的示例:

    $message = 'Check out this cute pic.';
    $attachment = array(
          'name' => 'i\'m bursting with joy',
          'href' => 'http://icanhascheezburger.com/2009/04/22/funny-pictures-bursting-with-joy/',
          'caption' => '{*actor*} rated the lolcat 5 stars',
          'description' => 'a funny looking cat',
          'properties' => array('category' => array(
                                'text' => 'humor',
                                'href' => 'http://www.icanhascheezburger.com/category/humor'),
                                'ratings' => '5 stars'),
          'media' => array(array('type' => 'image',
                                 'src' => 'http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg',
                                 'href' => 'http://icanhascheezburger.com/2009/04/22/funny-pictures-bursting-with-joy/')),
          'latitude' => '41.4',     //Let's add some custom metadata in the form of key/value pairs
          'longitude' => '2.19');
    $action_links = array(
                          array('text' => 'Recaption this',
                                'href' => 'http://mine.icanhascheezburger.com/default.aspx?tiid=1192742&recap=1#step2'));
    $attachment = json_encode($attachment);
    $action_links = json_encode($action_links);
    $facebook->api_client->stream_publish($message, $attachment, $action_links);
    

    查看this 以了解有关您可以包含哪些附件的更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-28
      • 2011-03-09
      • 2019-08-12
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多