We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

queuecalls.php and writing to the api directly

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
cwilliamson
Posts: 3
Joined: Mon Aug 22, 2016 4:14 pm

queuecalls.php and writing to the api directly

Post by cwilliamson »

My company's website currently uses a simple html form to post to queuecalls.php. Our current method requires that a user downloads a file from our site and then selects it from their machine to execute the post to queuecalls.php. I need to find a way to post without the need for that user interaction. Can you provide any advise or sample code to help me achieve this? Is the creation of a file 100% necessary?

Thanks,
Carl

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: queuecalls.php and writing to the api directly

Post by support »

Hi Carl,

Yes, the file portion of that process is necessary, as the queuecalls.php web service does require a file of contacts for which to dial. However, it does sound like you could shorten and fully automate that process with a little scripting. Instead of downloading the file from your site and then uploading it to the web form, you could simply create the file (or download it programmatically) and then make the web service call from within your script to the queuecalls endpoint. This way you could just run your single script that does all of those steps at once.

Here's a very basic sample that executes the queuecalls.php script via curl with a txt file of contacts, which you could easily alter to add downloading/creating of the existing contacts file. The phone_list file itself only needs to contain a phone number to be dialed on each line. A sample of this contacts file could be as simple as:

contacts.txt

Code: Select all

6177123000
8885551234
queuecalls.php

Code: Select all

<?php
// here you could build the contacts txt file, download it via CURL, etc.

// set parameters
$post_vars = array(
	'login'=>'your_login', // your login for your hosting account
	'pin'=>'your_pin', // your outbound pin for your hosting account
	'campaign_name' => 'mycampaign123',
	'phone_list' => '@test.txt', //pretend test.txt is in the same directory as this script for the sake of a sample
	'start_url'=>'http://example.com/start.php', // the publicly available url for your vxml script to use in the outbound call
	);

// make the request to the queuecalls api
$ch = curl_init();
// set curl options
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'multipart/form-data'); // because we're uploading a file
curl_setopt($ch, CURLOPT_URL, "http://outbound.plumvoice.com/webservice/queuecalls.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vars);
// execute curl request
$result = curl_exec($ch);
curl_close($ch);
echo $result;
Hopefully that gets you pointed in the right direction, but please let us know if you have any additional questions.

Regards,
Plum Support

cwilliamson
Posts: 3
Joined: Mon Aug 22, 2016 4:14 pm

Re: queuecalls.php and writing to the api directly

Post by cwilliamson »

Great, thanks! I'll give that a shot.

cwilliamson
Posts: 3
Joined: Mon Aug 22, 2016 4:14 pm

Re: queuecalls.php and writing to the api directly

Post by cwilliamson »

Is there any way to do this without creating a file?

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: queuecalls.php and writing to the api directly

Post by support »

Hi Carl,

Yes, it is possible to queue without a file. However, we would not recommend doing so if you are queuing a lot of calls at once. In order to accomplish this you would need to queue each call individually utilizing our singular queuecall.php endpoint. The queuecalls.php endpoint was built for the purpose of bulk queuing, as a file ensures you can upload many many contacts without issue and all calls will be processed at the same time. If you're queuing only a few calls at once and don't really care about them all getting processed at the same point in the queue, you should be able to queue them one by one. Here's a link to our documentation for that endpoint: http://www.plumvoice.com/docs/dev/plumd ... ifications

Here's a sample of queuing a single call:

queuecall.php

Code: Select all

<?php
// set parameters
$post_vars = array(
	'phone_number'=>'1115554444, // destination number
	'login'=>'your_login', // your login
	'pin'=>'your_outbound_pin', // your outbound dev pin
	'start_url' => "http://example.com/test.php", // start_url for your call script
	);

// make the request to the queuecalls api
$ch = curl_init();
// set curl options
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, "http://outbound.plumvoice.com/webservice/queuecall.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vars);
// execute curl request
$result = curl_exec($ch);
curl_close($ch);
echo $result;
Please let us know if you have any additional questions.

Regards,
Plum Support

Post Reply