2

我需要使用参数发布 Facebook 帖子。我从这里使用了解决方案: Generating Facebook Open Graph meta tags dynamic and here:Dynamic Facebook og Meta Tags in Wordpress PHP

最终工作代码:

<?php

$params = array();
if(count($_GET) > 0) {
    $params = $_GET;
} else {
    $params = $_POST;
}
// defaults
if($params['title'] == "") $params['title'] = "default_title";
if($params['score'] == "") $params['score'] = "1234567";

?>

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
  xmlns:fb="https://www.facebook.com/2008/fbml"> 

<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# pathoflight: http://ogp.me/ns/fb/pathoflight#">
  <meta property="fb:app_id"         content="MY_APP_ID" /> 
  <meta property="og:type"           content="pathoflight:level" /> 
  <meta property="og:url"            content="<?php echo 'https://path-of-light.herokuapp.com'.$_SERVER['REQUEST_URI']; ?>"/>
  <meta property="og:image"          content="https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png" /> 
  <meta property="og:title"          content="<?php echo $params['title']; ?>" /> 
  <meta property="pathoflight:score" content="<?php echo $params['score']; ?>" />
</head>

它在浏览器和 Facebook 调试器中完美运行,但我通过 Facebook API Explorer 发布的帖子总是会导致 和 的默认titlescore。如何让 Facebook 读取我的真实参数?

4

1 回答 1

0

问题还在于,如果您发布这样的帖子,Facebook API Explorer 会跳过参数

me/pathoflight:complete?level=https://path-of-light.herokuapp.com/level_new.php?title=my_title&score=223322

这种方法有效:

me/pathoflight:complete
Add a field
level     https://path-of-light.herokuapp.com/level_new.php?title=my_title&score=223322
于 2013-03-13T13:50:13.863 回答