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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀