2012-05-04 12 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について

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

をドキュメントhere

+0

ありがとうございます。ありがとうございます。ありがとうございますが、あなたはより具体的に、共有プロパティを使用して共有リンクを有効にすることはできますか?このドキュメントでは、共有リンクについて何も言及していません。 – teel

+0

アクション:[ {text: 'Game'、href: 'http://www.example.com/'} ]、 –

+0

「example.com」に行く「Game」というリンクを作成するだけです。私がしたいのは、通常のステータス更新のように、ユーザーが自分の壁に投稿を共有できる共有リンクを作成することです。 – teel

0

を参照して、タイトル、説明、あなたのページの先頭に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

関連する問題