API:Data Submission
From HasOffers
Complex Objects
The most common complex object we use is the "data" object which depending on the api call contains different elements. For those using php we provide examples. For those not using php, the method of posting fields to this object is simple. For each field in the data object you will need to post to a separate post field name. Take as an example the below array example.
data => array( 'name' => 'My Offer' ,'preview_url' => 'preview_url' ,'offer_url' => 'offer_url' ,'expiration_date' => '2015-01-01' )
This will be serialized for posting as below.
data[name]=MyOffer&data[preview_url]=preview_url&data[offer_url]=offer_url&data[expiration_date]=2015-01-01
For further nested data elements you can do data[object][object_property] to as many levels as necessary.
Arrays
In order to submit values to an array you will need to post many values to a single field. If for example you need to post a list of ids to the Offer:findAllByIds function you can post them as follows.
The field name of "ids[0]" will be the first array element and "ids[1]" will be the second. This is the manner our php examples use to post data. In order to simplify posting fields from other systems that do not implement a similar serialization tool, you can post them instead by using the single field name of "ids[]" for all of your individual array elements. In a get string this would look like "?ids[]=first&ids[]=second&ids[]=third". Each "ids[]" element will be read as part of the array.
Email this page to a friend or co-worker