使用PHP进行Facebook状态更新 [英] Facebook status update with PHP

查看:128
本文介绍了使用PHP进行Facebook状态更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是从我的网站更新会员状态,我也在考虑展示他们的朋友的照片和他们的最新状态更新。



我已经看过docs并且不能决定哪些适合我的需要。 RESTful API,JavaScript API,FQL,XFBML,FBML,FBJS? whcin一个最好?或者最好的方式?



应该是,当他们第一次去页面时,只会有一个登录选项。当他们点击它时,应该出现一个弹出窗口,当他们被授权时,我们显示一个文本区域来发布更新。在这里,我也想在他们回来后再次向他们展示他们的朋友的照片。



他们应该能立即发布,不能再要求再次登录。

有些人可以帮我代码吗?我不希望你写一切,把朋友的照片和他们最后一次更新成一个PHP数组将是很好的。



非常感谢

解决方案

如果您需要更新存储在ur数据库中的用户数据,那么您将使用facebook API来检查用户登录并获取他的数据。我在Facebook上有一个ifram应用程序,我正在使用C#代码(asp.net应用程序),当用户请求应用程序时,我认证他已经登录到Facebook,并检查他是否已经存在于我的数据库中?如果不是这样,我得到他的信息(通过使用Facebook API),并添加用户在我的数据库,每次他访问申请我更新他的信息。



尊重给他的朋友,我得到用户朋友的所有Facebook ids,然后循环这些ID,并获取每个ID的图片。
下载Facebook开发者工具包,使您能够与Facebook沟通并使用Facebook API获取用户信息。



希望这将有助于您



在Facebook上访问我的应用程序,您将在以下链接中看到这些功能:
http://apps.facebook.com/hanggame/



获取会话密钥:

  protected void Page_Load(object sender,EventArgs e)
{
//与Facebook用户集成的Facebook代码:
_fbService.ApplicationKey =应用程序密钥;
_fbService.Secret =秘密密钥;
_fbService.IsDesktopApplication = false;
string sessionKey =(string)Session [Facebook_session_key];
if(Session [Facebook_userId]!= null)
userId =(long)Session [Facebook_userId];

//当用户使用Facebook登录页面时,此处的重定向将在查询中具有auth_token参数
string authToken = Request.QueryString [auth_token];
if(!String.IsNullOrEmpty(sessionKey))
{
_fbService.SessionKey = sessionKey;
_fbService.uid = userId;
}
else if(!String.IsNullOrEmpty(authToken))
{
_fbService.CreateSession(authToken);
会话[Facebook_session_key] = _fbService.SessionKey;
会话[Facebook_userId] = _fbService.uid;
会话[Facebook_session_expires] = _fbService.SessionExpires;
}
else
{
Response.Redirect(@http://www.Facebook.com/login.php?api_key=+ _fbService.ApplicationKey + @& ; v = 1.0\" );
}
userId = _fbService.uid;
//结束Facebook代码
}


My requirement was to update members status from my site, i am also thinking about displaying their friends photos and their last status update.

I have looked all over the docs and cant decide which works for my need. RESTful API, JavaScript API, FQL, XFBML, FBML, FBJS ?? whcin one works best? or best way?

It should be like, when they first go to the page,there will be nothing but a login option. when they click on it, a pop up should appear and when they are authorized, we display a text area to post update. Here, i wanted to show their friends pics too

when they came back later, they should able to post right away, must not ask for login again.

Can some one help me with the code?? I dont expect you to write everything, get the friends pic and their last update into a PHP array would be nice.

Many thanks

解决方案

If u need to update users data stored at ur database so u will use the facebook API to check user signed in and get his data. i have an ifram application at facebook and i am using C# code (asp.net application) and when the user request the application i authenticate that he is signed in to facebook and check if he is already exist in my database? if not so i get his information(by using facebook API) and add the user in my data base and each time he visits the application i update his information.

With respect to his friends i get all facebook ids of the user friends and then loop these IDs and get the pic of each ID. Download Facebook Developer Toolkit that enables u communicate with facebook and use facebook API to get user information.

hope that is will help u

Visit my application in facebook and u will see these features at the following link : http://apps.facebook.com/hanggame/

Getting the session Key :

 protected void Page_Load(object sender, EventArgs e)
    {
        //Facebook code for integration with facebook users:
        _fbService.ApplicationKey = "Application Key";
        _fbService.Secret = "Secret Key";
        _fbService.IsDesktopApplication = false;
        string sessionKey = (string)Session["Facebook_session_key"];
        if (Session["Facebook_userId"] != null)
            userId = (long)Session["Facebook_userId"];

    // When the user uses the Facebook login page, the redirect back here will will have the auth_token in the query params
    string authToken = Request.QueryString["auth_token"];
    if (!String.IsNullOrEmpty(sessionKey))
    {
        _fbService.SessionKey = sessionKey;
        _fbService.uid = userId;
    }
    else if (!String.IsNullOrEmpty(authToken))
    {
        _fbService.CreateSession(authToken);
        Session["Facebook_session_key"] = _fbService.SessionKey;
        Session["Facebook_userId"] = _fbService.uid;
        Session["Facebook_session_expires"] = _fbService.SessionExpires;
    }
    else
    {
        Response.Redirect(@"http://www.Facebook.com/login.php?api_key=" + _fbService.ApplicationKey + @"&v=1.0");
    }
    userId = _fbService.uid;
    //End of Facebook code    
}

这篇关于使用PHP进行Facebook状态更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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