0

私はAppceleratorのModule.Facebookを使用してバッチ呼び出しを行うために探して約2時間を費やして使用してFacebookのバッチコールを呼び出します。私はプロフィールの名前と写真を入手する必要がありました。そして私は2つではなく1つのHTTPリクエストでこれをやりたいと思っていました。AppceleratorのModule.Facebookが

深いダイビングの後、私は最終的にやり方を見つけました。下記の回答セクションに私の回答を掲載します。

はIncaseの誰がこの直面しています。..

答えて

0
var fb = require('facebook'); 
var log = require("log"); 


... 

// After logging in 


// gets user profile image and name uses a batch method example 
    function getUserInfo(userId) { 

     var batch = 'batch=[{"method":"GET", "relative_url":"me"},{"method":"GET", "relative_url":"me/picture"}]&access_token=' + fb.getAccessToken(); 

     var url = "https://graph.facebook.com?" + batch; 
     var client = Ti.Network.createHTTPClient({ 
      // function called when the response data is available 
      onload : function(e) { 
       log.args(this.responseText);    

      }, 
      // function called when an error occurs, including a timeout 
      onerror : function(e) { 
       log.args(e.error); 
      }, 
      timeout : 5000 // in milliseconds 
     }); 

     // Prepare the connection. 
     client.open("POST", url); 
     // Send the request. 
     client.send(); 
    } 

これは、あなたがAPPCを使用してバッチ呼び出しを行うだろう方法です、しかし、私は必要な情報を得るためのより良い方法があります。私の場合はFacebookの名前と写真

function getGraphPath(userId) { 
     fb.requestWithGraphPath('me?fields=id,name,picture', {}, 'GET', function(e) { 
      if (e.success) { 
       log.args('Modules.Facebook.requestWithGraphPath', JSON.parse(e.result)); 
      } else if (e.error) { 
       log.args(e.error); 
      } else { 
       log.args('Unknown response'); 
      } 
     }); 
    } 
を必要と
関連する問題