2013-03-13 4 views
2

매개 변수가있는 Facebook 게시물을 만들어야합니다. 여기 Generating Facebook Open Graph meta tags dynamically과 : : 여기에서 솔루션을 사용 Dynamic Facebook og Meta Tags in Wordpress PHP매개 변수가있는 Facebook 게시물

최종 작업 CODE :

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

그것은 브라우저와 페이스 북 디버거에서 완벽하게 작동하지만, 페이스 북 API 탐색기를 통해 내 게시물은 항상 값을 기본값으로 리드 titlescore. Facebook에 내 실제 매개 변수를 읽으려면 어떻게해야합니까?

+0

은 오류가있는 URL이 제목에 대한 값을 표시하지 않습니다 또는 점수. 게시물 작성 중에 정확한 값을 전달하고 있습니까? "https://path-of-light.herokuapp.com/level_new.php?title=&score=" –

+0

@VishweshShetty 네, 물론입니다. 페이 스북 (Facebook)에서이 같은 게시글을 만듭니다. 그래프 탐색기 : me/pathoflight : complete? level = https : //path-of-light.herokuapp.com/level_new.php? title = my_title & score = 567765 – deko

+1

'add 필드 '옵션을 선택하고 url의 매개 변수로 레벨을 전달하는 대신'level '에 대해'https://path-of-light.herokuapp.com/level_new.php?title=my_title&score=567765 '를 사용하십시오. –

답변

0

문제 또한이

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

이러한 접근 방식과 같은 게시물을 작동 할 경우 페이스 북 API Explorer가 매개 변수를 생략이었다 :

me/pathoflight:complete 
Add a field 
level  https://path-of-light.herokuapp.com/level_new.php?title=my_title&score=223322 
관련 문제