2

on my site right now I'm trying to have it post to a users wall a media file.
I had it working on the old api before, but now I'm trying to get it working on the new one and I'm having an issue.

I'm running this

$facebook->api_client->stream_publish($message, $attachment, $action_links);

Is that the old api or the new one? Because I'm getting this error

Call to a member function stream_publish() on a non-object in

I was reading a tutorial and it said to do this

$statusUpdate = $facebook->api('/me/feed', 'post', array('message'=> 'the message', 'cb' => ''));

but how can I post an attachment/ action links using that?

Thanks!

Alberto Zaccagni
  • 30,779
  • 11
  • 72
  • 106
Belgin Fish
  • 19,187
  • 41
  • 102
  • 131

1 Answers1

4

First of all, don't confuse APIs with SDKs. The newest PHP SDK is capable of communicating with both the new Graph API and the old REST API.

And you are using the new SDK, since Facebook::$api_client doesn't exist in the new SDK.

Secondly, as is usual with most tutorials, they only show you a snapshot of the full features of a system. See here for more details about publishing with the Graph API.

However, you can still use the old API to publish your message like so

$facebook->api( array(
    'method'       => 'stream.publish'
  , 'target_id'    => $facebook->getUser()
  , 'message'      => $message
  , 'attachment'   => $attachment
  , 'action_links' => $action_links
) );
Peter Bailey
  • 105,256
  • 31
  • 182
  • 206
  • Trying to get this to work but struggling, can anyone help, looking to POST to a fan page with an mp3 media attachment. I can post a simple message but trying to add the media attachment array does not work. – paj Jun 07 '12 at 20:32