我想将Windows服务集成到用Tit闭锁创建的应用程序中,就像我们在Android中使用一样。我是新来和钛公司合作的。请帮助我提供一些有用的链接开始。
发布于 2013-07-29 13:31:37
我发现了这些:http://developer.appcelerator.com/question/149494/using-titanium-httpclient-to-access-windows-azure-mobile-services-rest-api
因为这是一个JavaScript库,所以应该会有所帮助。不过,可能有点旧了。http://azureblobstoragejs.codeplex.com/
发布于 2013-08-02 12:57:31
这就是我如何使用REST获取数据的方法。
function getWebserviceURL() {
return "https://database_name.azure-mobile.net/tables/";
}
function getCountryMasterData() {
var xhr = Titanium.Network.createHTTPClient();
xhr.onerror = function(e)
{
alert(e.toString);
};
xhr.onload = function() {
alert(this.responseText);
};
var request_url = getWebserviceURL() + "table_name";
xhr.open('GET', request_url);
xhr.setRequestHeader("Accept","application/json");
xhr.setRequestHeader("X-ZUMO-APPLICATION", "APP KEY");
xhr.setRequestHeader("Host", "database_name.azure-mobile.net");
xhr.send();
}发布于 2014-03-01 22:26:47
编辑:
我为编写了一个钛SDK。看看这里:https://github.com/rfaisal/tiny-azuresdk-titanium
原始答案:
首先登录facebook获取access_token (让我们称之为authorization_grant):
var fb=require('facebook');
fb.appid = 000000000000000; //replace this with your facebook app id
fb.permissions = ['email']; // add or remove permissions
fb.addEventListener('login', function(e) {
if (e.success) {
Ti.API.info('authorization_grant: '+fb.getAccessToken()); // prints to console, save for future use
}
});
fb.authorize();然后,从access_token获得authorization_grant(不是facebook,而是azure):
var authorization_grant = 'CAAHn34BO0R0BABtJyxdrZCQzakdmgJZBoQa0U...'; //saved from previous step
var xhr = Titanium.Network.createHTTPClient();
xhr.setTimeout(30000);
xhr.onload=function() {
Ti.API.info('access_token: '+JSON.parse(this.responseText).authenticationToken); // save this for requesting protected resource
};
xhr.onerror= function() {
Ti.API.info('Auth Failure response: '+this.responseText);
};
xhr.open('POST', 'https://my_resource_auth_server.azure-mobile.net/login/facebook');
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.send({
"access_token" : authorization_grant
});最后,通过access_token获取受保护的资源:
var access_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsI...'; //saved from previous step
var xhr = Titanium.Network.createHTTPClient();
xhr.setTimeout(30000);
xhr.onload=function() {
Ti.API.info('Protected Resource: '+this.responseText);
};
xhr.onerror= function() {
Ti.API.info('Error response: '+this.responseText);
};
xhr.open('GET', 'https://my_resource_auth_server.azure-mobile.net/api/some_resource');
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("X-ZUMO-AUTH", access_token); // this is the magic line
xhr.send();要获取需要应用程序级访问的资源,请添加一个名为X应用程序的标头,并传递从Azure网站获得的应用程序密钥。类似地,要访问需要管理级别访问的资源,请将从Azure网站获得的移动服务主密钥作为X主标题传递。
下面遵循的oAuth流是:

https://stackoverflow.com/questions/17875052
复制相似问题