我在嘗試做的是將用戶鍵入到itemSearch字段中的任何查詢,ping eBay的數據庫並返回帶有最多結果的categoryID。然而一旦測試,我收到以下錯誤:接收錯誤,說明我的httpRequest中的一個參數未定義
[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到從Objective-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.
}