简体   繁体   English

Facebook Open Graph API使用PHP或Javascript创建对象

[英]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. 我正在尝试创建一个Open Graph对象,以便与facebook open graph API中的操作一起使用。 I've tried using both the PHP and javascript based code provided by facebook on my app control center. 我尝试在我的app控制中心使用facebook提供的PHP和基于javascript的代码。 Under 'Open Graph' > 'Stories' > 'Get Code'. 在“打开图表”>“故事”>“获取代码”下。

Facebook tells me to use the following code: Facebook告诉我使用以下代码:

    $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. 运行Javascript版本时也会发生此错误。

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 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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