MattLoszak
MattLoszak

Reputation: 585

Facebook Open Graph API Create Object with PHP or Javascript

I'm trying to create an Open Graph object for use with an action in the facebook open graph API. I've tried using both the PHP and javascript based code provided by facebook on my app control center. Under 'Open Graph' > 'Stories' > 'Get Code'.

Facebook tells me to use the following code:

    $response = $facebook->api(
       'me/objects/music.song',
       'POST',
       array(
          'app_id' => (I Insert My App ID Here),
          'type' => "music.song",
          'url' => "http://samples.ogp.me/461258627226537",
          'title' => "Sample Song",
          'image' => "https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png",
          'album' => "Sample Album: URL",
          'preview_url' => "Sample Preview URL: URL",
          'description' => ""
       )
     );
     // handle the response

The error I get when I print out the response is:

    <b>Fatal error</b>:  Uncaught OAuthException: Cannot specify type in both the path and query parameter.

This error also occurs when I run the Javascript version.

I have tried removing the type, and messing around with all the parameters but nothing works; I get a host of other errors. If it would help, I can provide what exactly else I have tried and the errors that occur.

If this doesn't work I might try hosting the object on my own server, but this should be easy shouldn't it!? What am I missing??

Many thanks,

Matt

Upvotes: 4

Views: 2106

Answers (1)

Bilal Rabi
Bilal Rabi

Reputation: 149

If you want to post actions use this method

$response = $facebook->api(
  'me/og.likes',
  'POST',
  array(
    'object' => "URL OF THE PAGE HAVING META TAGS FOR POST"
  )
);
// handle the response
echo $response;

In the other code i m getting same errors today

Thanks

Upvotes: 1

Related Questions