|
@@ -5,27 +5,29 @@
|
|
|
|
|
|
import("facebook", "storage");
|
|
|
|
|
|
+var _u = import({}, "lib-support/useful");
|
|
|
+
|
|
|
fb.OAuthInterface = function () {
|
|
|
}
|
|
|
|
|
|
fb.OAuthInterface.prototype.restApi = function (method, 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;
|