앱이 그래프 API의 엔드 포인트에 HTTP의 POST를 호출하는 기사를 읽으 등
- 사용자가 응용 프로그램에 조치를 취 문서를 읽어 개념이 어떻게 작동하는지 이해할 필요/me/action : object = Object_URL
- Facebook은 개체 웹 페이지 (WordPress 페이지)를 크롤링하고 해당 메타 태그를 읽고 작업을 통해 개체를 사용자에게 연결합니다.
액션은 news.reads, 그래서 당신은 당신의 응용 프로그램 설정에서 기본 작업 유형 read
을 설정해야이 일을하기 위해
POST https://graph.facebook.com/me/news.reads?article=[article object URL in your Wordpress Blog]
를 다음과 같이 부를 것이다 : https://developers.facebook.com/apps/YOUR_APP_ID/opengraph
그런 다음 당신은 객체 세트에 대한 article
유형이 있어야합니다. 그런 다음 당신은 당신의 워드 프레스의 개체 URL을 설정해야합니다 이들은 삽입 메타 태그에 의해 수행되는 블로그
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#
article: http://ogp.me/ns/article#">
<meta property="fb:app_id" content="YOUR_APP_ID">
<meta property="og:type" content="article">
<meta property="og:url" content="URL of this object">
<meta property="og:site_name" content="Name of site hosting article">
<meta property="og:image" content="URL to an image">
<meta property="og:title" content="Name of article">
<meta property="og:description" content="Description of object">
<meta property="article:published_time" content="DateTime">
<meta property="article:modified_time" content="DateTime">
<meta property="article:expiration_time" content="DateTime">
<meta property="article:author" content="URL to Author object">
<meta property="article:section" content="Section of article">
<meta property="article:tag" content="Keyword">
</head>
<body>
<!-- main article body -->
</body>
</html>
그래서 당신은 당신의 header.php 또는 index.php 파일 파일에 다음을 둘 것 테마 설정에 따라 그런 다음 기능을 삽입해야하고 싶다면 테마 설정에 기초한 같은
포스트
<meta property="og:url" content="<?php the_permalink() ?>"/>
<meta property="og:title" content="<?php single_post_title(''); ?>" />
그런 다음 당신이 보풀이 필요 하나의 게시물 제목의 URL 제대로 설정했는지 확인하기위한 URL은
http://developers.facebook.com/tools/debug
su가되면 메타 태그가 제대로 설정되어 재 모든 것이이 작업의 ID를 반환해야합니다 설정하면 이전
POST https://graph.facebook.com/me/news.reads?article=[article object URL in your Wordpress Blog]
을 언급 한대로 작업을 테스트해야합니다.
그럼 당신은 JS SDK
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '[YOUR_APP_ID]', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
를 사용하여 인증을위한 논리와 로그인 버튼 플러그인
<fb:login-button show-faces="true" width="200" max-rows="1" scope="publish_actions"> </fb:login-button>
중 하나 functions.php 파일에 직접 단일 내를 구현해야합니다. php 및 index.php 페이지
페이지로드시 다음 작업을 호출하는 함수를 작성해야합니다.
<script type="text/javascript">
function readArticle()
{
FB.api(
'/me/news.reads',
'post',
{ article: 'http://yourwordpress.com/site/' },
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Article read was successful! Action ID: ' + response.id);
}
});
}
</script>
이 시점에서 필자는 편지를 작성해야합니까? POST https://graph.facebook.com/me/news.reads?article=[Article Word에서 귀하의 기사 객체 URL] 이 지점에서 이해가 안되는 질문입니다. –
@WawanDenFrastøtende는 HTTP POST를 나타냅니다. 테스트를 위해 cURL을 사용하거나 JS SDK를 사용할 수 있습니다. ^^^'FB.api ( '/ me/news.reads', ' – phwd
아직 이해가 안되고 앱을 만들고 또한 opengraph 또한 내 헤더와 함수에 opengraph 태그를 삽입하지만 게시물 페이지를 열려고하면 "오류가 발생합니다"라는 메시지가 나타납니다. 어떻게 도와 드릴 수 있습니까? –