doujingxi3356 2014-09-05 08:23
浏览 37
已采纳

javascript值存储在facebook test api中的php变量中

i get response using facebook api get all value in json and also get single value. this value i want to store in php variable any idea for that.

 function testAPI() {
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
         console.log(JSON.stringify(response));
      console.log('Successful login for: ' + response.name);
      document.getElementById('status').innerHTML =
        'Thanks for logging in, ' + response.email + '!';

        var email = response.email;
    });


  }

<div id="status" ></div>

i am create email varibale in script how to store as my php varibale can you plase suggest me?

  • 写回答

1条回答 默认 最新

  • dourang6423 2014-09-06 05:14
    关注
         function testAPI() {
        console.log('Welcome!  Fetching your information.... ');
        FB.api('/me', function(response) {
    
            var mydata = JSON.stringify(response);
            //console.log(mydata);
             //console.log(JSON.stringify(response));
          //console.log('Successful login for: ' + response.name);
          document.getElementById('status').innerHTML =
            'Thanks for logging in, ' + response.email + '!';
    
         //  setCookie("fb_user_data",JSON.stringify(response),"1");
    
          myajax(mydata);
    
    
    
    
          //  var email = response.email;
        });
    
        //delete_cookie('fb_user_data');    
      }
    
    function myajax(mydata){
    
        var mydata = mydata || "";
        var send_data = "fbdata="+mydata;
         $.ajax({
           type: "GET",
           url: "/learn_test/response.php",
           data: send_data,
           datatype : "json",
           success: function(response){
            console.log(response)
            /*alert(response.msg);
            alert(response.error);
            alert(response.run);*/
    
           }
            });
    }
    

    set response in reponse.php

    if(isset($_GET['fbdata'])){
    $fbarry = print_r(json_decode($_GET['fbdata']),true);
    $msg = array();
    $msg['msg'] = "done";
    $msg['error'] = "";
    $msg['run'] = true;
    //$msg['run'] = false;
     print_r(json_decode($_GET['fbdata']));
    }
    

    i can get the value.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办