【问题标题】:I want to create post with web site preview我想创建带有网站预览的帖子
【发布时间】:2013-04-29 19:40:54
【问题描述】:

我想创建一个带有网站预览的帖子。它必须与屏幕截图相似。

如何创建带有网络预览的帖子?我想在页面上添加它。

NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"Post with web preview",  @"message", nil];
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/feed", myself.pageID]
                                     parameters:dict HTTPMethod:@"POST" completionHandler:nil];   

【问题讨论】:

  • 该死......我本可以收集到这个赏金:/但我不想在两个不同的问题上重新发布相同的答案......
  • 我的回答 here 应该会为您提供所需的信息。基本上,你必须在你分享的 URL 上实现一些 og:meta 标签......这就是 Facebook 提取分享故事预览的方式......
  • 我的答案不是你要找的吗?
  • @Chococroc,我没有在你的代码中找到任何网页预览。
  • 你在问 CSS 问题吗?我的意思是,你想要的是看到你的 html 格式是这样的吗?

标签: facebook facebook-graph-api preview


【解决方案1】:

有关在此处发布链接(您称之为“发布网站预览”)的更多信息: http://developers.facebook.com/docs/reference/api/link/

我假设您的 Facebook 应用程序设置了您的权限,并且您正在使用 PHP-sdk 类。无论如何,任何语言的过程都是相同的,只是改变了你写它的方式。此外,您需要具有适当权限集的用户访问令牌。

使用 Facebook 的 PHP-sdk,流程如下:

// Load FB class, and init it
require_once("facebook.php");

$config = array();
$config['appId'] = 'YOUR_APP_ID';
$config['secret'] = 'YOUR_APP_SECRET';

$facebook = new Facebook($config);

// You set the User Access Token (you need to have it previously to this: Because you 
// requested before, or because you obtain it from Facebook)
$facebook->setAccessToken( $user_access_token );

try {
  // Set the link params:      
  if ( isset($config['link']) ) { 
     $args = array(
       'link'        => $link_url          //Url to be linked
     , 'name'        => $link_titulo       //Box title
     , 'description' => $link_descripcion  //Box Description
     , 'picture'     => $link_foto         //Photo to be posted
     , 'message'     => $link_message      //Message over the "link box"
     );

     // Post in the User/FB_Page wall
     $facebook->api('/me/feed', 'post', $args);
  }
} catch (FacebookApiException $e) {
     $fbError = $e->getResult();

  $result = array(
    'tipo'   => 'error'
  , 'code'   => $fbError['error']['code']
  , 'text'   => $fbError['error']['message']
  );

  print_r($result);
}

更新

阅读您对我的评论的回答后,我认为您只是在寻找 CSS 和布局。你可以在这里找到一些东西来实现帖子格式:

http://jsfiddle.net/5NYD5/3/

【讨论】:

    【解决方案2】:

    这可以通过多种方式完成,

    如果您使用的是 facebook API,那么它很简单,就像在 FB 上一样(图像将自动获取)

    Dim fb As FacebookClient = New FacebookClient('access_token')
    
    Dim args As Dictionary(Of String, Object) = New Dictionary(Of String, Object)()
    
    args("message") = "Your Message to be posted"
    args("link") = "http://www.example.com"
    
    fb.Post("/me/feed", args)
    

    我希望这样做,

    否则,如果您不使用 FB API,那么手动抓取图像或创建站点快照的方法相对较长。就像搜索引擎爬虫进入网站后爬取一样。很长的路要走,但有可能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多