mass_buy

Updated on December 22nd, 2013

Same as single buy but allows you to do mass automated purchases up to 2000 with one network connection

Resource URL

https://api.given.to/rests/mass_buy

Notes

You need to have a webhook url to use the mass_buy api, you can set it here

Parameters for POST field 'data'

campaign_id required

The numeric ID of the campaign this purchase is associated with. You can view a list of your existing campaigns and the ID of each here

Example Value: 123456

app_id required

The iTunes App ID of the app being purchased. Use the App ID Search Tool to find the ID of the app you want to send.

optionrequired

Download codes that are generated using this API method will be returned in the response when it is set to generate. The "generate" option is available for clients that prefer to deliver the link on their own. When this parameter is set to send, Given.to will send the code directly to the recipient using the values you've provided in the send_format and send_to parameters.

Example Values: send or generate

Default message for sms send: You received an iphone app as a gift from {Company Name}. Click here to download, ((short url))

numberrequired when option is set to generate

Maximum number you can generate is 2000

Example Values: any integer under 2000

send required when option is set to send

The send field is a json array containing the send_format and the send_to fields

Example Value: [{"send_format":"number","send_to":"3296705777"},{"send_format":"number","send_to":"3012670578"}, {...}, ... ]

Fields in JSON

  • send_format:

    The send_format tells us what type of information you are sending in your request to identify the intended recipient. Currently this parameter can be set to either "email" (to send the download link to an email address) or "phone" (to send the download link to a phone number via SMS). This field is required if the option parameter is set to "send".

    Example Value: email or phone

  • send_to:

    The email address or phone number of the intended recipient. Currently, only US phone numbers can be used. The country code is not necessary. Dashes are not necessary.

    Example Value for email: email@example.com

    Example Value for phone: 3014567890

  • Example

    Sample Request: Buy an App with PHP & cURL and send to specific person

    <?php
    
            $url = 'https://api.given.to/rests/mass_buy'; 
            
            // Mass Buy
            $send = array();
            $send_form['send_format'] = 'number';
            $send_form['send_to'] = '3013456789';
            array_push($send, $send_form);
            $send_form['send_format'] = 'number';
            $send_form['send_to'] = '3012670578';        
            array_push($send, $send_form);
    
            $json_hold['send'] = $send;
    	$json_hold['app_id'] = '329670577'; //Camera+
    	$json_hold['campaign_id'] = 1; 
            $json_hold['option'] = 'send';
    	$json = json_encode($json_hold);
    
    	$data = array(
    		'auth_key' => 'YOUR_KEY', 
    		'auth_secret' => 'YOUR_SECRET', 
    		'data' => $json
    	);
    	
    	$ch = curl_init($url);
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($ch, CURLOPT_POST, 1);
    	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    	$response = curl_exec($ch);
    	curl_close($ch);
    
    	echo "<pre>";
    	print_r($response);
    	echo "</pre>";
    
    ?>
    				

    Response

    status

    1 means we received your requests and 0 means your request completely failed

    message

    A detailed message of the status. This will show if the status is 0

    queue (Will not show if status is zero)

    A json array of your queued requests id. The status for everything in this field will be 'PROCESSING' as it will be placed in the queue

  • request_id: Id of the request being processed
  • send_to (If option is send): Who this is going to
  • send_format (If option is send): The format of send_to
  • Sample Response for generate option

    {
        "status":1,
        "message":"Your requests have been put into a queue",
        "queue":[
                    {"request_id":"3816"},{"request_id":"3817"}
                ]
    }
    				

    Sample Response for send option

    {
        "status":1,
        "message":"Your requests have been put into a queue",
        "queue":[
                    {"request_id":"3831","send_format":"number","send_to":"3013456789"},
                    {"request_id":"3832","send_format":"number","send_to":"3012670578"}
                ]
    }