Facebook Open Graph API Create an Object Using PHP or Javascript

I am trying to create an Open Graph object for use with an action in the facebook open graph facebook API. I tried using the PHP and javascript code provided by facebook in my application control center. In the "Open Graph"> "Stories"> "Get Code" section.

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 

Error receiving response:

  <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 tried to remove this type and mess with all the parameters, but nothing works; I get many other errors. If this helps, I can provide what else I tried and the errors that occur.

If this does not work, I can try to host the object on my own server, but it should be easy, right ?? What am I missing?

Thank you very much,

Matt

+4
source share
1 answer

If you want to post your 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 another code, I get the same errors today

thanks

+1
source

Source: https://habr.com/ru/post/1486026/


All Articles