0

I'm trying to post into a Facebook wall using PHP. I've found this code:

$args = array(
    'message' => $text,
    'picture' => $link2picture
);

$this->_facebook->api('/me/feed/', 'post', $args);

but it doesn't seems to work (it only displays the message text). So my question is, there is any way to post a picture only, linking it to a page? I'm trying to avoid uploading the photo to Facebook and also i don't want to use the standard 'share link' that shows the small picture aligned to the left; my idea is just to display the image thumbnail, may be a description before or after the image and when users click over that image then he is redirected to a given page. Can this be done? How?

EDIT: I've also tried this code, with no success:

$attachment = array(
'name' => $title,
'caption' => 'The subtitle',
'description' => $message,
'media' => array(array(
    'type' => 'image',
    'src' => $file_path,
    'href' => $link
))
);
$this->facebook->api(array('method' => 'stream.publish', 'target_id' => $this->getUser(), 'attachment' => $attachment));
Kara
  • 6,115
  • 16
  • 50
  • 57
FidoBoy
  • 392
  • 6
  • 18

1 Answers1

0

Just try this :

$attachment = array('message' => $message, 'access_token' => $token, 'picture' => $picture_path);

$result = $facebook->api('/me/feed', 'post', $attachment);

Enjoy :)

Ravinder Singh
  • 3,113
  • 6
  • 30
  • 46