2

I want to create a post with web site preview. It must be similar as on screenshot.

enter image description here

How do I create a post with web preview? I want to add it on pages.

NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"Post with web preview",  @"message", nil];
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/feed", myself.pageID]
                                     parameters:dict HTTPMethod:@"POST" completionHandler:nil];   
NSSplendid
  • 1,957
  • 1
  • 13
  • 14
Voloda2
  • 12,359
  • 18
  • 80
  • 130

2 Answers2

2

More info about posting links (what you call "post with web site preview") here: http://developers.facebook.com/docs/reference/api/link/

I asumme you have your Facebook APP with your permissions set, and that you're using PHP-sdk classes. Anyway, the proccess is the same for any language, just changing the way you write it. Also, you need the user Access Token with the proper permission set.

Using the PHP-sdk from Facebook, process would be:

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

Update

After reading your answer to my comment, I think you're looking just for the CSS and the layout. You can find something to achive the post formatting here:

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

Federico J.
  • 15,388
  • 6
  • 32
  • 51
1

This can be done using multiple ways,

If you are using facebook API then its easy, just like on FB(image will be automatically fetched)

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)

I hope this will do,

else if you are not using FB API then its comparatively long way to grab image or create snapshot, of site manually. Just like search engine crawlers crawl after entering website. Its long way but yes possible.

MarmiK
  • 5,639
  • 6
  • 40
  • 49