我尝试做的是将用户输入的任何查询带入itemSearch字段,ping eBay的数据库,并返回结果最多的categoryID。但是,经过测试,我收到以下错误:
[9067:3603] Error: Uncaught Error: Can't set params if there is already a query parameter in the url (Code: 141, Version: 1.2.18)
删除params周围的引号并没有解决问题,我觉得这是因为我没有正确格式化params以便从目标中获取值 - c代码。任何帮助,将不胜感激!
我的云代码结构如下:
Parse.Cloud.define("eBayCategorySearch", function(request, response) {
url = 'http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=*APP ID GOES HERE*';
Parse.Cloud.httpRequest({
url: url,
params: {
'OPERATION-NAME' : 'findItemsByKeywords',
'SERVICE-VERSION' : '1.12.0',
'RESPONSE-DATA-FORMAT' : 'JSON',
'callback' : '_cb_findItemsByKeywords',
'itemFilter(3).name=ListingType' : 'itemFilter(3).value=FixedPrice',
'keywords' : 'request.params.item',
// your other params
},
success: function (httpResponse) {
// deal with success and respond to query
},
error: function (httpResponse) {
console.log('error!!!');
console.error('Request failed with response code ' + httpResponse.status);
}
});
});
我在我的iOS应用程序中调用该函数,如下所示:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if (sender != self.nextButton) return;
if (self.itemSearch.text.length > 0) {
[PFCloud callFunctionInBackground:@"eBayCategorySearch"
withParameters:@{@"item": self.itemSearch.text}
block:^(NSNumber *category, NSError *error) {
if (!error) {NSLog(@"Successfully pinged eBay!");
}
}];
}
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
答案 0 :(得分:0)
错误消息告诉您错误。
您已将网址定义为
url = 'http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=*APP ID GOES HERE*'
但是它包含一个查询字符串("?"之后的位),因此您收到错误消息。
您需要将网址设置为
url = "http://svcs.ebay.com/services/search/FindingService/v1"
并添加
"SECURITY-APPNAME" : "*APP ID GOES HERE*"
到你的params词典