2012-05-04 5 views
1

FB.ui를 사용하는 FB에 작은 응용 프로그램을 만들어 사용자가 벽에 공유 할 수 있도록했습니다. 공유 된 게시물이 "댓글"과 "좋아요"옆에있는 "공유"링크를 표시하도록하고 싶습니다. 정상적인 벽 게시물과 같습니다.FB.ui를 사용할 때 게시물에 대한 링크 공유

FB.ui에서이를 수행 할 수있는 방법이 있습니까?

또는 벽 포스트에 맞춤 이미지, 제목, 설명 등을 정의 할 수있는 다른 방법이 있습니까?

내 현재 코드 :

function share(name, description) { 
     FB.ui({ 
      method: 'feed', 
      name: name, 
      picture: '/img/fb.png', 
      link: url, 
      caption: '', 
      message: '', 
      description: description 
      }, function() { 
      }); 
    } 

답변

5

는이 share_open_graph 방법으로 수행 할 수 있습니다. 코드는 다음과 같아야합니다.

FB.ui({ 
    method: 'share_open_graph', 
    action_type: 'og.shares', 
    action_properties: JSON.stringify({ 
     object : { 
      'og:url': 'http://astahdziq.in/', // your url to share 
      'og:title': 'Here my custom title', 
      'og:description': 'here custom description', 
      'og:image': 'http://example.com/link/to/your/image.jpg' 
     } 
    }) 
    }, 
    // callback 
    function(response) { 
    if (response && !response.error_message) { 
     // then get post content 
     alert('successfully posted. Status id : '+response.post_id); 
    } else { 
     alert('Something went error.'); 
    } 
}); 
+0

이 질문이 제기 된 후에이 방법이 추가되었다고 생각합니다.하지만이 질문은 당시 내가 찾고 있었던 것과 같습니다. 감사. – teel

+0

이것이 누군가를 도울 수 있다면 기쁩니다. :) –

-1

당신은 이 문서 the share action를 들어 here

+0

감사합니다.하지만 좀 더 구체적으로 공유 속성을 사용하여 공유 링크를 활성화 할 수 있습니까? 이 문서에는 공유 링크에 대한 언급이 없습니다. – teel

+0

작업 : [ {text : 'Game', href : 'http://www.example.com/'} ], –

+0

그러면 "example.com"으로 이동하는 "Game"이라는 링크가 생깁니다. 내가 뭘하고 싶은지는 사용자가 정상적인 상태 업데이트와 같이 자신의 벽에 게시물을 공유 할 수있는 공유 링크를 만드는 것입니다. – teel

0

를 참조 행동 속성을 사용할 필요가

FB.ui({ 
    method: 'share', 
    href: 'https://developers.facebook.com/docs/', 
}, function(response){}); 

사용자 정의 이미지, 제목을 정의하려면, 설명, 당신 페이지의 머리에 Open Graph Tags을 사용하십시오 :

<meta property="og:url" content="http://samples.ogp.me/136756249803614" /> 
<meta property="og:title" content="Chocolate Pecan Pie" /> 
<meta property="og:description" content="This pie is delicious!" /> 
<meta property="og:image" content="https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/851565_496755187057665_544240989_n.jpg" /> 

효과는 다음과 같습니다

enter image description here

관련 문제