Windows Azure的身份验证Bing搜索在Objective-C [英] Windows Azure Authentication for Bing Search in Objective-C

查看:147
本文介绍了Windows Azure的身份验证Bing搜索在Objective-C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在12年8月1日兵修改了他们的搜索API到Azure的,我怎么能在Objective-C认证使用新的必应搜索API从Azure的?

On 01.08.12 Bing modified their search api to a Azure, How can I authenticate in Objective-C to use the new bing search api from Azure?

我最好的猜测是从迁移word文档中提供的PHP的例子来学习! http://go.microsoft.com/fwlink/?LinkID=248077 (呵呵上帝,你不能设置一个网页)或该Java问题! - <一个href=\"http://stackoverflow.com/questions/11136936/bing-search-api-azure-marketplace-authentication-in-java\">Bing搜索API Azure的市场验证Java中

My best guess is to learn from the provided PHP example in the migration word document!! http://go.microsoft.com/fwlink/?LinkID=248077 (Oh god, can't you setup a web page!) or this Java Question - Bing Search API Azure Marketplace Authentication in Java

推荐答案

我使用ASIHTT prequest与以下code认证。

I'm using ASIHTTPRequest to authenticate with following code.

NSString *queryString = [NSString stringWithFormat:@"'%@'", queryString];
queryString = [queryString urlEncodeUsingEncoding:NSUTF8StringEncoding]; //You'll have to implement url encoding method, preferably in a string category file

NSString *urlString = [NSString stringWithFormat:@"https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Image?Query=%@&Market='en-US'&$top=50&$format=json", queryString];

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:urlString] ];
[request setAuthenticationScheme:(NSString *)kCFHTTPAuthenticationSchemeBasic];
[request setUsername:@"YOUR_KEY_HERE"];
[request setPassword:@"YOUR_KEY_HERE"];
[request setDelegate:self];
[request startAsynchronous];

请注意,没有APPID必需的。只是,而不是通过用户名及密码,您的钥匙。它成功地获取数据。

Please note, no appID required. just instead pass your key as username and password. It is successfully getting the data.

但是,不能真正的数据转换成的NSString。想尽编码,但无法从数据字符串。最初的谷歌搜索说,这是UTF-8 EN codeD。但没有成功。

However, can't really convert the data to NSString. tried every encoding but can't get the string from the data. Initial googling says it's UTF-8 encoded. But no success.

有关上述code正常工作,您必须添加ASIHTTP框架。

For above code to work, you must add ASIHTTP framework.

另一件事是,我的猜测是路过的base64 EN codeD字符串格式your_key:yourkey也应该有基本的认证工作。

Another thing is, my guess is passing base64 encoded string with this format your_key:yourkey should also work with basic authentication.

这篇关于Windows Azure的身份验证Bing搜索在Objective-C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆