简体   繁体   中英

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

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 im getting same errors today

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM