2
兩個詞,我試圖做一個叫喊查詢並使用OAuth庫無效的簽名,同時通過在Yelp的URL
下面是代碼
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
eg但是,如果我添加兩個詞,如term=petrol+fuel
,它開始給我錯誤{"error": {"text": "Signature was invalid", "id": "INVALID_SIGNATURE", "description": "Invalid signature
這段代碼有什麼問題?
示例API請求
http://api.yelp.com/v2/search?term=cream+puffs&location=San+Francisco
它包含一個+,但是當我使用+它給我上面的錯誤
你的代碼是罰款,去yelp API文檔,看看那裏如何在單個查詢中使用多個參數,看看它是否可能,希望這會幫助你 – Talha
@Talha這是一個SAMple請求在文檔http://api.yelp.com/v2/search?term = cream + puffs&location = San + Francisco –
根據您的示例請求,在我看來,請求罰款時,像奶油泡芙是一個食品名稱,因此它是寫在請求奶油+泡芙(+)加號表明這是一個單詞而你的字汽油+燃料是不是一個單詞這些是兩個不同的術語,你可以做到這一點汽油+泵或燃料+站等,希望這可能會幫助你 – Talha