-1

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?

coder
  • 105
  • 15

1 Answers1

0
     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.

coder
  • 105
  • 15