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
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集