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

Facebook;发布到FanPage的链接

  •  0
  • Gazillion  · 技术社区  · 15 年前

    我有一个Web应用程序,允许用户在他们的网站上发布一篇文章时发布一个小的Blurb。现在,我可以使用保存在表中的会话键发布到用户的墙,但不能在风扇页上发布相同的链接(我拥有所需页面的权限和ID)。

    本质上,我想要的功能是: http://wiki.developers.facebook.com/index.php/Links.post 而是一页纸。到目前为止,我所能找到的都是使用steam.publish函数,这与以前的功能不太一样。

    我希望在link.post函数中有一个隐藏的参数(比如target_id),而我错过了这个参数(因为facebook wiki很恐怖)。

    感谢您的帮助:)如果没有函数,也许有人可以帮助我使用stream.publish的参数使文章的内容看起来相同?

    1 回复  |  直到 15 年前
        1
  •  2
  •   Gazillion    15 年前

    好吧,我找不到一种方法来使用link_post()函数发布到一个fanpage,所以我决定改变流的形状。以一种看起来相同的方式发布结果。为了得到同样的效果,我不得不围绕变量跳很多舞,但效果很好。在本例中,我必须获取“描述”元标记、页面内容中的第一个图像和页面标题。

    我希望这能帮助别人:

    $title = 'Title of the article, or the title of your webpage';
    $message = 'Caption that will go with the link, from the user';
    $description = 'I put what would have been in the description metatag, which is what the post link seems to grab';
    $fb_thumbnail = ''; // a link to the first image in your article
    $target_id = 'XXXXXX'; // the id of the fan page you want to post to
    
    $attachment = array( 'name' => $title,
                    'href' => 'http://'.$url,
                    'description' => $description,
                    'media' => array(array('type' => 'image',
                                    'src' => $fb_thumbnail,
                                    'href' => 'http://'.$url))); // I would get an error with the HREF but that's because I wasn't including the "http://" bit in the link
    
                    $attachment = json_encode($attachment);
    
                    $facebook->api_client->stream_publish($message, $attachment,"",$target_id);
    
    推荐文章