分享至Facebook后重定向用户和发布 [英] redirect user after facebook share and publish

查看:255
本文介绍了分享至Facebook后重定向用户和发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  https://www.facebook.com/dia​​log/feed?
APP_ID = 123050457758183&安培;
链接= HTTPS://developers.facebook.com/docs/reference/dialogs/&
图片= HTTP://fbrell.com/f8.jpg&
名实=%20Dialogs&安培;
标题=参考%20Documentation&安培;
说明=使用%20Dialogs%20to%20interact%20with%20users和放大器。
消息= Facebook的%20Dialogs%20顷%20so%20easy&放!;
REDIRECT_URI = HTTP://www.example.com/response

上面的例子用户相同的URL,他是否点击发布或跳过重定向。

我试过下面给出的例子:

 <脚本>
  FB.init({APPID:ID,状态:真的,饼干:真});  功能postToFeed(){    //调用API ...
    VAR OBJ = {
      方法:'喂',
      链接:链接分享,
      图片:GGGG,
      名称:GGG,
      标题:GGG。,
      说明:GGG。
    };    回调函数(响应){
      的document.getElementById('味精')的innerHTML =后成功发布,帖子ID:+响应['POST_ID'] +点击这里;无功海峡=点击这里激活新的时间表Facebook的个人主页!
的document.write(str.link(重定向URL HERE));
 }    FB.ui(OBJ,回调);
  }

但是上面的例子也无法得到结果。


解决方案

 <脚本类型=文/ JavaScript的>
FB.init({APPID:YOUR_APP_ID状态:真的,饼干:真});
  功能share_me(){
    FB.ui({
      方法:'喂',
      APP_ID:YOUR_APP_ID',
      链接:SHARE_URL',
      图片:PIC_URL',
      名称:'SHARE_NAME',
      标题:SHARE_CAPTION',
      说明:SHARE_DESCRIPTION
    },
    功能(响应){
      如果(响应和放大器;&安培; response.post_id){
        self.location.href ='SUCCESS_URL
      }
      其他{
        self.location.href ='CANCEL_URL
      }
    });
  }
&所述; /脚本>中;
  < D​​IV的onclick =share_me()>共享和LT; / DIV>

这是你的不同了一点,但我希望你的想法。我们用我们自己的框架,所以我不能保证FB的初始化是正确的:(

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.

解决方案

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

这篇关于分享至Facebook后重定向用户和发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆