Facebook 分享和发布后重定向用户

发布于 2025-01-07 15:01:55 字数 1216 浏览 0 评论 0原文

如果用户发布,如何将用户重定向到特定 URL,如果用户跳过,如何重定向到不同的 URL?

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。

我尝试了下面给出的示例:

   <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);
  }

但是上面的示例也无法给出结果。

How can I redirect a user to a specific URL if the user publishes and to a different URL if he skips?

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

The above example redirects the user to same URL whether he clicks publish or skip.

I tried the example given below:

   <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);
  }

But the above example also is unable to give results.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

墨小墨 2025-01-14 15:01:55
<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 初始化是正确的:(

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

A bit different from yours but I hope you get the idea. We're using our own framework so I can't guarantee the FB initialization is correct :(

缘字诀 2025-01-14 15:01:55
window.fbAsyncInit = function() {
    FB.init({
      appId            : 'FACEBOOK_APP_ID',
      autoLogAppEvents : true,
      xfbml            : true,
      version          : 'v3.3'
    });
  };
	function share_me(url,productlink) {
	FB.ui({
  method: 'share_open_graph',
      app_id: 'FACEBOOK_APP_ID',
      link: 'REDIRECT_URL',
       action_type: 'og.likes',
  action_properties: JSON.stringify({
    object:
	  {
		 'og:url': productlink, 
		'og:image': url 
	  }
  })
	
}, function(response){
  // Debug response (optional)
  if(response && response.post_id) {
        self.location.href = 'SUCCESS_URL'
      }
      else {
        self.location.href = 'CANCEL_URL'
      }
		
});
	self.location.href = 'REDIRECT_URL';	
	}
<script async defer src="https://connect.facebook.net/en_US/sdk.js"></script>

<div onclick="share_me()">Share</div>

window.fbAsyncInit = function() {
    FB.init({
      appId            : 'FACEBOOK_APP_ID',
      autoLogAppEvents : true,
      xfbml            : true,
      version          : 'v3.3'
    });
  };
	function share_me(url,productlink) {
	FB.ui({
  method: 'share_open_graph',
      app_id: 'FACEBOOK_APP_ID',
      link: 'REDIRECT_URL',
       action_type: 'og.likes',
  action_properties: JSON.stringify({
    object:
	  {
		 'og:url': productlink, 
		'og:image': url 
	  }
  })
	
}, function(response){
  // Debug response (optional)
  if(response && response.post_id) {
        self.location.href = 'SUCCESS_URL'
      }
      else {
        self.location.href = 'CANCEL_URL'
      }
		
});
	self.location.href = 'REDIRECT_URL';	
	}
<script async defer src="https://connect.facebook.net/en_US/sdk.js"></script>

<div onclick="share_me()">Share</div>

把昨日还给我 2025-01-14 15:01:55
<a href="https://www.facebook.com/dialog/share?app_id=YOUR_APP_ID&display=popup&href=<?php echo get_permalink($product->id) ;?>&redirect_uri= REDIRECT_URL "><span>Share me</span></a> 

<a href="https://www.facebook.com/dialog/share?app_id=YOUR_APP_ID&display=popup&href=<?php echo get_permalink($product->id) ;?>&redirect_uri= REDIRECT_URL "><span>Share me</span></a> 

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文