2012-02-20 11 views
1

ユーザーを公開する場合は特定のURLにリダイレクトし、スキップする場合は別のURLにリダイレクトするにはどうすればよいですか?Facebookの共有後にユーザーをリダイレクトして公開する

https://www.facebook.com/dialog/feed? 
app_id=123050457758183& 
link=https://developers.facebook.com/docs/reference/dialogs/& 
picture=http://fbrell.com/f8.jpg& 
name=Facebook%20Dialogs& 
caption=Reference%20Documentation& 
description=Using%20Dialogs%20to%20interact%20with%20users.& 
message=Facebook%20Dialogs%20are%20so%20easy!& 
redirect_uri=http://www.example.com/response 

上記の例では、公開するかスキップするかにかかわらず、ユーザーを同じURLにリダイレクトしています。

Iは、下記の例を試みた:

<script> 
    FB.init({appId: " id", status: true, cookie: true}); 

    function postToFeed() { 

    // calling the API ... 
    var obj = { 
     method: 'feed', 
     link: 'link to share', 
     picture: 'gggg', 
     name: 'ggg', 
     caption: 'ggg.', 
     description: 'ggg.' 
    }; 

    function callback(response) { 
     document.getElementById('msg').innerHTML = "Post successfully published, Post ID: " +  response['post_id'] + " click here"; 

var str = "Click here to activate your new timeline facebook profile!"; 
document.write(str.link("redirection url here")); 


} 

    FB.ui(obj, callback); 
    } 

をしかし、上記の例では、結果を与えることができません。

答えて

2
<script type="text/javascript"> 
FB.init({appId: "YOUR_APP_ID", status: true, cookie: true}); 
    function share_me() { 
    FB.ui({ 
     method: 'feed', 
     app_id: 'YOUR_APP_ID', 
     link: 'SHARE_URL', 
     picture: 'PIC_URL', 
     name: 'SHARE_NAME', 
     caption: 'SHARE_CAPTION', 
     description: 'SHARE_DESCRIPTION' 
    }, 
    function(response){ 
     if(response && response.post_id) { 
     self.location.href = 'SUCCESS_URL' 
     } 
     else { 
     self.location.href = 'CANCEL_URL' 
     } 
    }); 
    } 
</script>"; 
    <div onclick="share_me()">Share</div> 

少し違っていますが、私はあなたのアイデアを得ることを願っています。私たちは独自のフレームワークを使用しているため、FBの初期化が正しいことを保証することはできません:(

+0

URLを成功させた投稿をURLに置き換える必要がありますか? –

+0

はい、self.location .href = 'your_url_here'またはtop.location.href = 'your_url_here'あなたのニーズに応じて –

+0

okありがとう..私は試してみて、あなたに教えて.. –

関連する問題