简体   繁体   English

在客户端使用JSON获取fb访问令牌

[英]Get fb access token using JSON on client side

How can I retrieve my data using JSON 如何使用JSON检索数据

my sample code 我的示例代码

test.js(client side) test.js(客户端)

function(){
$.getJSON("https://graph.facebook.com/oauth/authorize?client_id=appid&redirect_uri=http://domain.com/sample/index.php", function(data) {
    alert(data.userName);
});
}

index.php(server side) index.php(服务器端)

<?php
    $aReturn['userName'] = "carlo2893";
    echo json_encode($aReturn);
?>

but it doesn't return any. 但不会返回任何内容。

Not sure what you are trying to achieve, but you most likely need 不确定要达到的目标,但是您很可能需要

  1. register your application in http://developers.facebook.com http://developers.facebook.com中注册您的应用程序
  2. include facebook's init javascript - see https://developers.facebook.com/docs/reference/javascript/ 包括facebook的初始化javascript-请参阅https://developers.facebook.com/docs/reference/javascript/
  3. once you got access token, you can use it on backend 一旦获得访问令牌,就可以在后端使用它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM