• Dear Forum,

    I need to embed a contact form on a single page of my wordpress blog. The company providing the contact form, ShootQ, has an API in place which I understand will help in implementation. I’m not sure how to go about this. I believe I need to create a .php file and upload it to my template. Then somehow I need to place a “call” to this code on my page so the form will load. On their website, they have an example of the php file (I’ve removed my specific API keys for safety reasons…

    can someone talk me through this? Do I make a notepad document with the code below (named: commentform.php) and upload to my server? How do I then insert the form on my single page (in the body of the post). thanks in advance!!!!

    Eric

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    <?php

    /* define the account specific variables for this ShootQ user */
    $api_key = “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”;
    $brand_abbreviation = “my_brand_abbreviation”;

    /* create the URL to POST our data to */
    $url = “https://app.shootq.com/api/&#8221;.$brand_abbreviation.”/leads”;

    /* create a data structure to send to ShootQ */
    $lead = array();
    $lead[‘api_key’] = $api_key;
    $lead[‘contact’] = array();
    $lead[‘contact’][‘first_name’] = ‘John’;
    $lead[‘contact’][‘last_name’] = ‘Doe’;
    $lead[‘contact’][‘phones’] = array();
    $lead[‘contact’][‘phones’][0] = array();
    $lead[‘contact’][‘phones’][0][‘type’] = ‘Home’;
    $lead[‘contact’][‘phones’][0][‘number’] = ‘(555) 555-1212’;
    $lead[‘contact’][’emails’] = array();
    $lead[‘contact’][’emails’][0] = array();
    $lead[‘contact’][’emails’][0][‘type’] = ‘Home’;
    $lead[‘contact’][’emails’][0][’email’] = ‘[email protected]’;
    $lead[‘contact’][‘role’] = ‘Groom’;
    $lead[‘event’] = array();
    $lead[‘event’][‘type’] = ‘Wedding’;
    $lead[‘event’][‘date’] = ’10/12/2008′;
    $lead[‘event’][‘referred_by’] = ‘Some Referrer’;
    $lead[‘event’][‘remarks’] = ‘Some <b>HTML</b> encoded <i>remarks</i>!’;
    $lead[‘event’][‘wedding’] = array();
    $lead[‘event’][‘wedding’][‘ceremony_location’] = ‘First Church of ShootQ’;
    $lead[‘event’][‘wedding’][‘ceremony_start_time’] = ’17:30′;
    $lead[‘event’][‘wedding’][‘ceremony_end_time’]= ’18:30′;
    $lead[‘event’][‘wedding’][‘reception_location’] = ‘ShootQ Party Central’;
    $lead[‘event’][‘wedding’][‘reception_start_time’] = ’19:00′;
    $lead[‘event’][‘wedding’][‘reception_end_time’]= ’22:00′;
    $lead[‘event’][‘wedding’][‘groomsmen_count’] = 5;
    $lead[‘event’][‘wedding’][‘bridesmaids_count’] = 5;
    $lead[‘event’][‘wedding’][‘guests_count’] = 200;
    $lead[‘event’][‘extra’] = array();
    $lead[‘event’][‘extra’][‘Your Favorite Color’] = ‘Green’;

    /* encode this data structure as JSON */
    $lead_json = json_encode($lead);

    /* send this data to ShootQ via the API */
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, Array(“Content-Type: application/json”));
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $lead_json);

    /* get the response from the ShootQ API */
    $response_json = curl_exec($ch);
    $response = json_decode($response_json);
    $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    /* the HTTP code will be 200 if there is a success */
    if ($httpcode == 200) {
    echo “SUCCESS!\n”;
    } else {
    echo “There was a problem: “.$httpcode.”\n\n”;
    echo $response_json;
    }

    /* close the connection */
    curl_close($ch);

    ?>

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Embedding a Contact form on single page’ is closed to new replies.