2017-04-25 25 views
0

WebアプリケーションでYammer Login SDKを実装したばかりです。ログインしたら、私はこのコードをうまく利用者情報を見ることができます:Yammer SDK - ユーザー情報を取得する(JSONからPHPへ)

yam.getLoginStatus(
function(response) { 
if (response.authResponse) { 
    console.log("logged in"); 

    yam.platform.request({ 
    url: "users/current.json", //this is one of many REST endpoints that are available 
    method: "GET", 
    data: { //use the data object literal to specify parameters, as documented in the REST API section of this developer site 
     "page": "2", 
    }, 
    success: function (user) { //print message response information to the console 
     alert("The request was successful."); 
     console.dir(user); 

    }, 
    error: function (user) { 
     alert("There was an error with the request."); 
    } 
    }); 

} 
else { 
    alert("not logged in") 
} 
} 
); 

しかし、これが唯一の私のコンソールログでJSON「オブジェクト」としての私の情報が表示されます。 この情報をすべてMySQLデータベースにアップロードできるように、このGET情報にアクセスしたいと思います。これは私が私のコンソールログに情報を参照する方法である。

JSON Object

私は基本的に私はPHPでそれを使用することができますので、この情報にアクセスする必要があります。

+0

「GET」情報?あなたはあなたの全体のHTTP要求応答を意味しますか? – hassan

+0

@hassanはいそれは私が意味するものです – CharlotteOswald

+0

'response'オブジェクト全体をあなたのコンソールに表示し、あなたの望む要素を選択してください。 – hassan

答えて

0

POST AJAXに直接渡すようにコードを変更しました。

functionyam.getLoginStatus(
function(response) { 
if (response.authResponse) { 

    $.ajax({ 
     type:'POST', 
     url: 'functions/test.php', 
     data:response, 
     success:function(data){ 
      $("#usershow").empty(); 
      $("#usershow").delay(300).fadeIn(200).append(data); 
     }, 
     error: function(data){ 
      $("#usershow").empty(); 
      $("#usershow").append("There was a problem with your query. Please try again later."); 
     } 
     }); 

} 
else { 
    yam.platform.login(function (response) { //prompt user to login and authorize your app, as necessary 
    if (response.authResponse) { 

    $("#usershow").text('OTHER IF FUNCTION'); 
    } 
    }); 
} 
} 
); 
関連する問題