Page 1 of 1


PostPosted: Thu May 27, 2010 12:25 am
by sentm
An OSDial API is forthcoming.

The first function add_lead currently allows for remote insertion from CRMs or other webspace via XML into the leads table and/or directly into the hopper for immediate dialing.

Here is a preview of the XML post for the add_lead function:
Code: Select all
<?xml version='1.0' standalone='yes'?>
<api user="admin" pass="XXXXX" function="add_lead" mode="admin" test="0" debug="0" vdcompat="0">


    <address1>1234 Test Ave</address1>
    <address2>Apt. 31-B</address2>
    <comments>This is a test of the lead loading.</comments>

      <additional_field form="CREDITCARD" field="NAME">John Doe</additional_field>
      <additional_field form="CREDITCARD" field="ADDRESS">9928 CC Lane</additional_field>


So the question for you developers our there is...what functions do you think you can benefit from?

Re: OSDial API

PostPosted: Tue Apr 19, 2011 5:58 pm
by fsanchez
Hi, I can see you have a few interesting posts!

I have a question in reference to this one in particular if you have a chance, i saw in the Features List in the website that OSDial is "Ready to import XML formatted leads from web site"

Do you know how can that option be implemented?? I appreciate your time. Thank you.

Re: OSDial API

PostPosted: Tue Apr 19, 2011 10:24 pm
by sentm
The above example is a good starting point...

There is a draft version of the API Documentation also available. It goes into a bit more depth on the add_lead call.

Disclaimer: Being that it is a draft version, there may be mistakes in the document and/or API itself.

Re: OSDial API

PostPosted: Mon Apr 25, 2011 10:02 am
by fsanchez
Thank you very much that was very helpful

Re: OSDial API

PostPosted: Wed May 11, 2011 3:59 pm
by fsanchez
But how my clients, can send me a xml via api.php. This is that i dont understand.

Re: OSDial API

PostPosted: Wed May 11, 2011 4:53 pm
by sentm
Via HTTP POST, using the xml variable.

Re: OSDial API

PostPosted: Sat May 14, 2011 3:53 pm
by fsanchez
This is the code, would you please correct me

<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="ufile" />
<input type="submit" value="Upload" />

because the help explain: http://yourserver/admin/api.php?xml=<api function="version"/>
but what is =<api function="version"/> this is that my clients, dont undertand

Re: OSDial API

PostPosted: Sat May 14, 2011 7:01 pm
by sentm
Almost. You can't pass it an html file input, but you could post a textarea into the API. You would have to copy and paste you XML into the textarea, but it should work just fine.

Code: Select all
<form action="" method="post" enctype="multipart/form-data">
<textarea name="xml" rows="15" cols="80">Paste you XML file here and click submit.</textarea>
<input type="submit" value="Upload" />

I would recommend using JavaScript or Curl as a transport for getting information into the API.
Here is an example of a script that uses Curl to post back to the API.

Re: OSDial API

PostPosted: Wed May 18, 2011 12:22 pm
by fsanchez
Thank You, for the help. We apreciate your guidelines.
We Finally have a solution:
This is the code:

$filename = "sample_xml1.xml";
$handle = fopen($filename, "rb");
$data = '';
while (!feof($handle)) {
$data .= fread($handle, 8192);
<form action="" method="post" enctype="multipart/form-data">
<textarea name="xml" rows="30" cols="80"><?php echo $data; ?></textarea>
<input type="submit" value="Upload" />

Now we have another question for you.
What if we need to send by xml, multiples rows of information. Because this xml example is only of one row.
Thank for your answer.

Re: OSDial API

PostPosted: Wed May 18, 2011 11:27 pm
by sentm
Well, first I would prearrange a format in which to receive the data, lets say CSV. It would then require you to write code to receive the file and parse/loop through it, creating the needed xml structures, posting the xml structure to the API via Curl or Javascript XMLHttpRequest(), and then report on the result.

Code: Select all


if ( !isset($_POST['submit']) or !isset($_FILES['leadfile']) ) {
  # If they havent submitted or the file was not set redisplay form.
  echo "<form action=\"$PHP_SELF\" method=\"post\" enctype=\"multipart/form-data\">\n";
  echo "<input type=\"file\" name=\"leadfile\">\n";
  echo "<input type=\"submit\" value=\"Upload\">\n";
  echo "</form>\n";

} else {
  # Good, they submitted and a file was attached.  Lets get it.
  $leadfile = $_FILES['leadfile'];
  $leadfiletmp = $_FILES['leadfile']['tmp_name'];
  $leadfilename = $_FILES['leadfile']['name'];

  # We are going to assume hear that the format is alway csv and the uploader is consistent.
  while ($row=fgetcsv($leadfiletmp, 1000, ',')) {
    # The uploaded only sends us the following fields in this order: custid, phone, fname, lname

    # Lets make an xml sturcture!
    $xmlReq = new SimpleXMLElement('<api><params></params></api>');
    # Now we need to add all the required components from the API docs...

    # Auth - CHANGE user AND pass values for a user that is allowed API access!
    $xmlReq['user']     = '1000';
    $xmlReq['pass']     = '1000';
    $xmlReq['function'] = 'add_lead';
    $xmlReq['mode']     = 'admin';
    $xmlReq['vdcompat'] = '0';
    $xmlReq['test']     = '0';
    $xmlReq['debug']    = '0';

    # Parameters / DataControl - These flags change how the lead is validated and how to act on it.
    $xmlReq->params->dnc_check         = 'Y';
    $xmlReq->params->duplicate_check   = 'LIST';
    $xmlReq->params->gmt_lookup_method = 'AREACODE';
    $xmlReq->params->add_to_hopper     = 'Y';
    $xmlReq->params->hopper_priority   = '50';
    $xmlReq->params->hopper_local_call_time_check    = 'N';
    $xmlReq->params->hopper_campaign_call_time_check = 'N';

    # Parameters / ListData - Variables that apply to every lead loaded in this list.
    $xmlReq->params->list_id          = '20110518211054'; # The list_id should exist and be assigned to a campaign.
    $xmlReq->params->vendor_lead_code = 'FSAN'; # Use this so you can later identify what vendor the leads came from.
    $xmlReq->params->source_id        = 'WEB'; # The lead source ?  Web/ Email/ Mail/ Phone...
    $xmlReq->params->phone_code       = '1';
    $xmlReq->params->status           = 'NEW';

    # Parameters / LeadData - The Actual lead data.
    $xmlReq->params->external_key     = $row[0];
    $xmlReq->params->phone_number  = $row[1];
    $xmlReq->params->first_name        = $row[2];
    $xmlReq->params->last_name         = $row[3];

    # Done with xml lets attempt to send it to the API!
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, '');
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, array('xml' => $xmlReq->asXML()));
    $result = curl_exec($ch);

    # Print out the result of the last attempt.
    $xmlRes = new SimpleXMLElement($result);
    echo $xmlRes->status ."<br/>";

    # Continue on to next entry in file.

  echo $leadfilename . " has been processed.<br/>";


I haven't tested the above code...its just what I could come up with in 10 min. It could use counters and styles. Hopefully you have a basic concept of what it is doing.

Re: OSDial API

PostPosted: Tue May 24, 2011 3:55 pm
by fsanchez
That was very helpful thank you!

Re: OSDial API

PostPosted: Wed Feb 17, 2016 4:39 pm
by wayneski
Hi, I appreciate the last post in in this topic was 2011, Thank you to sentm for the contribution, it has been a great basis to get some code running.

I have had some success in importing leads into OSDials standard out of the box fields however when I try to import into any of the custom fields there is no data posted in those specific fields. Again the standard fields are populated.

$xmlReq->params->additional_fields = "<additional_fields>";
$xmlReq->params->additional_field = "<additional_field form=\"CREDITCARD\" field=\"NAME\">Smith</additional_field>";
$xmlReq->params->additional_fields = "</additional_fields>";

Can anyone assist me with this as I've been banging my head on the wall.

I have purchased the OSDIAL Manual which shows it possible, so I guess it could be my PHP skills that are letting me down.

Thank you in advance and I hope this helps someone else in the future.