2

私はyelpクエリを実行しようとしていますが、OAuthLibを使用しています

これがコードです

  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;

クエリに1つの用語がある場合、コードは完全に機能します。term=petrolたとえば、2つの用語を追加すると、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

iTSには+が含まれていますが、+を使用すると、上記のエラーが発生します

4

1 に答える 1

0

文字列をUTF8エンコーディングでエンコードし、現在は正常に機能しています

于 2013-01-17T14:20:43.200 に答える