Question

Parse's documentation states that a cloud function would look like so:

[PFCloud callFunctionInBackground:@"averageStars"
                   withParameters:@{@"movie": @"The Matrix"}
                            block:^(NSNumber *ratings, NSError *error) {
  if (!error) {
     // ratings is 4.5
  }
}];

However, I can't seem to figure out where the API request would be placed if I wanted to ping eBay's item database. The format of the request I'm referring to is below:

var url = "http://svcs.ebay.com/services/search/FindingService/v1";
    url += "?OPERATION-NAME=findItemsByKeywords";
    url += "&SERVICE-VERSION=1.0.0";
    url += "&SECURITY-APPNAME=MyAppID";
    url += "&GLOBAL-ID=EBAY-US";
    url += "&RESPONSE-DATA-FORMAT=JSON";
    url += "&callback=_cb_findItemsByKeywords";
    url += "&REST-PAYLOAD";
    url += "&keywords=harry%20potter";
    url += "&paginationInput.entriesPerPage=3";
Was it helpful?

Solution

The request to PFCloud class is used to interact with parse's servers, it can't connect directly with third party services.

You can however, interact with third party services via http requests. You can perform an httpRequest via your cloud code function. Http requests are pretty standard JavaScript, you can read about them here!

If eBay has a javascript library, you might be able to wrap it as a custom module and use it that way. You can read about that here.

And, just a reminder, Make sure you're not doing anything too heavy, as timeout is I think, 15 seconds.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top