我正在尝试进行yelp查询并使用OAuth Lib
这是代码
NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"http://api.yelp.com/v2/search?term=petrol+restaurants&ll=%f,%f&radius_filter=300",coordinate.latitude,coordinate.longitude]];
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:consumerKey secret:consumerSecret];
OAToken *token = [[OAToken alloc] initWithKey:tokenUrl secret:tokenSecret];
id<OASignatureProviding, NSObject> provider = [[OAHMAC_SHA1SignatureProvider alloc] init];
NSString *realm = nil;
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:URL
consumer:consumer
token:token
realm:realm
signatureProvider:provider];
[request prepare];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
connection = nil;
如果查询有一个术语term=petrol
,则代码可以正常工作,例如但如果我添加两个术语,例如term=petrol+fuel
,则会开始给我错误{"error": {"text": "Signature was invalid", "id": "INVALID_SIGNATURE", "description": "Invalid signature
此代码有什么问题?
SAMPLE API REQUEST
http://api.yelp.com/v2/search?term=cream+puffs&location=San+Francisco
iTS包含一个+但是当我使用+时它会给我上面的错误
答案 0 :(得分:0)
我使用UTF8编码编码了字符串,现在运行良好