› Forums › API Integrations › OAP API usage
This topic has 3 voices, contains 9 replies, and was last updated by Mark Winstein 200 days ago.
| Author | Posts |
|---|---|
| Author | Posts |
| September 13, 2011 at 6:37 pm #1839 | |
|
|
Hi, I have a product (cart in clickbank) and if a client purchase my product, I want to call OAP API to add the details of the client who purchased my product to my OAP contacts. If the client or contact is already there, I just want to update his info about the product that he purchased. I have reviewed the API Documentation on the wiki, but did not find any way or at least a code snippet on how to do this or how to initiate a call to OAP API. Any reference on how to do this is highly appreciated. I am coding this by the way in PHP. Thanks. Sal |
| September 13, 2011 at 7:29 pm #1840 | |
|
|
Hi Sal, Thank you very much for writing. Here is sample working code for adding a new record. When using the “Add” request type on Contacts, if a Contact record with the given email already exists, the data posted by this script will overwrite any existing data in the fields named by the script. To test this script, first create an App ID and API Key from the menu Admin -> OfficeAutoPilot API Instructions and Key Manager. Insert the resulting ID and Key in the noted places in the code below and post the whole script on your server as is to test it. The goal of this script sample is just to get you to “proof of concept” for adding and updating records in Office Autopilot. If you have additional questions about this code or making it work for your specific situation, please post your next questions below and we’ll work through your project together. Cheers, <?php
//Add or Update a Contact
header("Content-Type: text/plain");
echo "<pre>";
$data = <<<STRING
<contact><Group_Tag name="Contact Information"><field name="First Name">BOB</field><field name="Last Name">TESTER</field><field name="E-Mail">bob@bobtester.com</field><field name="City">Portland</field></Group_Tag><Group_Tag name="Sequences and Tags"><field name="Contact Tags">TEST TAG</field></Group_Tag></contact>
STRING;
$data = urlencode(urlencode($data));
$appid = "XXXXXXXXXXXXX"; // PUT YOUR APP ID HERE
$key = "XXXXXXXXXXXXX"; // PUT YOUR APP KEY HERE
$reqType= "add";
$postargs = "appid=".$appid."&key=".$key."&return_id=1&reqType=".$reqType. "&data=" . $data;
$request = "http://api.moon-ray.com/cdata.php";
$session = curl_init($request);
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $postargs);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
//THE FOLLOWING LINE SHOWS THE RAW DATA
echo "RAW OUTPUT\n";
echo "=====================\n";
echo $response;
echo "\n\n\n";
$xml = new SimpleXMLElement($response);
//THE FOLLOWING LINE SHOWS THE DATA ORGANIZED BY XML ATTRIBUTES
echo "NICE XML OUTPUT\n";
echo "=====================\n";
print_r($xml);
echo "\n\n\n";
echo "</pre>";
?>
|
| September 14, 2011 at 6:45 am #1856 | |
|
|
Hi Mark, Just tested the code snippet you provided and it worked! yey! great! Thanks Much! Sal |
| October 1, 2011 at 12:07 am #1869 | |
|
|
Hi Mark, How are you! I just have a follow up question with regards to OAP API. How can I update the purchase history and transactions of my contacts dashboard using the OAP API? What I have right now is just updating the contact with new information details based on the email. Thanks. Sal |
| October 2, 2011 at 6:53 pm #1870 | |
|
|
Hi Sal, Near the bottom of Office Autopilot’s API Guide you can find a fully coded example of adding a sale transaction using the $reqType = “sale”; The Add Contact script above was built from this model. If you look nearer to the top of OA’s API guide in the area called Sale Type (Purchases) you can find the full structure of the Sale request. Only a small piece of that structure is used in their example. Best regards, |
| October 2, 2011 at 7:00 pm #1871 | |
|
|
Hi Mark, Oh bummer, so it was just all right here. Thanks, Sal |
| November 2, 2011 at 4:23 pm #1885 | |
|
|
Hi Mark, OfficeAutoPilot support said you can help. I’m trying to integrate OAP into existing web-site, using OAP REST API, everything seems to work fine, except credit card info, “Card Type” and “Card Expiration Month” fields, which have “tdrop” type do not accept string nor numeric data, when I try to fill them using the API (by setting “January” or 1 for month field for example) – they become blank. Is there a way to pass this credit card info to OAP through REST API? And if there’s one, how it should be done? Thanks, |
| November 2, 2011 at 6:07 pm #1886 | |
|
|
Hi Dimitry, I have not tried to write to fields in the Credit Card group. So your first step is to request that OA’s tech support team ask the API side if you can write to the fields you desire. You’re just looking for a yes or no answer here. If the answer is “yes” post another note for more guidance on how to write to text drop down list fields via Office Autopilot’s API. It is doable and we’ve done it here. Cheers, |
| November 3, 2011 at 7:47 am #1887 | |
|
|
Hi Mark, Thanks for your response, I have another, more basic question, I’m adding products to the contact using $reqType = “sale”;, but they all are marked as “already purchased”, without payment transaction. If there’s no way of purchasing products through rest api – then i have no use in credit card info filling, and the only way – is to use html forms. Best regards, |
| November 3, 2011 at 8:30 am #1888 | |
|
|
Hi Dimitri, Office Autopilot does not currently offer API access to its order form payment processing. An order form is a limited version of a shopping cart. OA’s API makes it easy to integrate with other shopping carts. Most good carts have an API which can be used to pass the info on successful transactions into OA. OA’s logic here is that there are so many great carts – picking a great cart is at the heart of building an eCommerce site. OA’s competitor Infusionsoft has a built in cart, but it is much harder to integrate 3rd party carts into Infusionsoft’s API. One of the coolest things about OA’s system is that all you have to do is get the product into the product table via API and all the related automations can be set and changed on the fly from the user interface. With Infusionsoft, if you do a cart integration, you also need to specifically name any actions sets, sequences, and tags in your code.
|
You must be logged in to reply to this topic.