Kaynağa Gözat

possibly fixed
debug output left

Herbert Vojčík 13 yıl önce
ebeveyn
işleme
c4161e9194
1 değiştirilmiş dosya ile 8 ekleme ve 6 silme
  1. 8 6
      lib-app/facebook-oauth.js

+ 8 - 6
lib-app/facebook-oauth.js

@@ -5,27 +5,29 @@
 
 import("facebook", "storage");
 
+var _u = import({}, "lib-support/useful");
+
 fb.OAuthInterface = function () {
 }
 
 fb.OAuthInterface.prototype.restApi = function (method, args) {
 //  return wget("https://api.facebook.com/"+method+this.tokenString(), args);
-  print("https://api.facebook.com/method/"+method+this.tokenString(), args);
-  print(wget("https://api.facebook.com/"+method+this.tokenString(), args, {complete:true}));
+  print("https://api.facebook.com/method/"+method, this.withToken(args));
+  print(wget("https://api.facebook.com/"+method, this.withToken(args), {complete:true}));
   response.stop();
 };
 
 fb.OAuthInterface.prototype.graphApiGet = function (path, args) {
-  return wget("https://graph.facebook.com/"+path+this.tokenString(), args);
+  return wget("https://graph.facebook.com/"+path, this.withToken(args));
 };
 
 fb.OAuthInterface.prototype.graphApiPost = function (path, args) {
-  return wpost("https://graph.facebook.com/"+path+this.tokenString(), args);
+  return wpost("https://graph.facebook.com/"+path, this.withToken(args));
 };
 
-fb.OAuthInterface.prototype.tokenString = function () {
+fb.OAuthInterface.prototype.withToken = function (args) {
   var token = this._token || (this._token = this.obtainToken());
-  return token ? "?access_token="+encodeURIComponent(token) : "";
+  return token ? _u.extend({access_token:token}, args) : args;
 };
 
 fb.free = new fb.OAuthInterface;