dtwy2858 2011-10-31 03:58
浏览 50
已采纳

为WordPress新用户获取Facebook JSSDK变量?

I've setup a Facebook application and properly installed the Facebook Javascript SDK.

When visiting the site, user profile information is automatically displayed if they're logged into Facebook. (Exactly what I want).

I tried installing the PHP SDK earlier, however it requires the Connect and authorization, so once the page is loaded it will prompt me to Login - even though I'm logged into Facebook already. There are some other minor bugs I didn't like about the PHP SDK as well, so I've decided to ditch it and go with only the JS.

I can access the Profile name, email, gender, etc. and have those saved as separate JS variables as well as within separate

tags. The site is a WordPress site, and the goal is to automatically add anyone logged into Facebook as WordPress users.

  1. Visitor arrives at site and are logged into Facebook.
  2. The JS SDK retrieves their profile information.
  3. The information is displayed on the screen.
  4. ... Need to find a way to retrieve this information and place it inside

wp_create_user ('$facebookusername', $'facebookemail', 'defaultpassword')

I've been stuck on this problem for awhile and have only come up with the following possibilities.... - Access the cookie from Facebook ??? - Does the JS SDK include a JSON object that could be converted to a PHP array?

Thanks everyone and this site is excellent!

  • 写回答

1条回答 默认 最新

  • duanrang3357 2011-10-31 05:57
    关注

    You can get all information using js sdk and graph api and it will send the data in the json format.

    Once you got the information just make ajax call to your php where it will get the input and do whatever you want.

    And php has the 'json_decode' function which will convert the json data into an array..

    To call the graph api using js sdk , use FB.api method

    FB.api('/me', function(response) {
      alert(response.name); 
      // here send a ajax request to a php script with the 'response' as data
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog