首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >用钛与Windows

用钛与Windows
EN

Stack Overflow用户
提问于 2013-07-26 07:08:30
回答 3查看 865关注 0票数 0

我想将Windows服务集成到用Tit闭锁创建的应用程序中,就像我们在Android中使用一样。我是新来和钛公司合作的。请帮助我提供一些有用的链接开始。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 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/

票数 1
EN

Stack Overflow用户

发布于 2013-08-02 12:57:31

这就是我如何使用REST获取数据的方法。

代码语言:javascript
运行
复制
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();
}
票数 1
EN

Stack Overflow用户

发布于 2014-03-01 22:26:47

编辑:

我为编写了一个钛SDK。看看这里:https://github.com/rfaisal/tiny-azuresdk-titanium

原始答案:

首先登录facebook获取access_token (让我们称之为authorization_grant):

代码语言:javascript
运行
复制
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):

代码语言:javascript
运行
复制
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获取受保护的资源:

代码语言:javascript
运行
复制
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://rfaisalblog.wordpress.com/2014/03/01/oauth-flow-for-mobile-apps-with-an-external-identity-server/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17875052

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档