Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## input.php, receives $_POST data from a simple .html file
- ## handles the $_POST and forms it into qbXML
- <?php
- // Require the queueuing class
- require_once 'QuickBooks.php';
- // Require the mysql class
- require_once 'mysql.php'
- // Require the qb server
- require_once 'server.php'
- $dsn = 'mysql://qb:3rJjKc6ybHRrPCde@localhost/qb';
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- //$open = mysql_connect($db->host, $db->user, $db->password);
- //mysql_select_db('qb_sql')
- // Insert into our local MySQL database
- //mysql_query("INSERT INTO qb_customer ( Name, Fullname, email ) VALUES ( '" . $_POST['customer']['name'] . "', '" . $_POST['customer']['phone'] . "', '" . $_POST['customer']['email'] . "' ) ");
- //$id_value = mysql_insert_id();
- // QuickBooks queueing class
- $queue = new QuickBooks_Queue($dsn);
- // Queue it up!
- $queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, 5);
- ?>
- ## server.php
- ## Quickbooks SOAP Server
- // Require the framework
- require_once 'QuickBooks.php';
- $user = 'Admin';
- $pass = '<PASSWORD>';
- // Map QuickBooks actions to handler functions
- $map = array(
- QUICKBOOKS_ADD_CUSTOMER => array( '_quickbooks_customer_add_request', '_quickbooks_customer_add_response' ),
- // ... more action handlers here ...
- );
- // This is entirely optional, use it to trigger actions when an error is returned by QuickBooks
- $errmap = array();
- // An array of callback hooks
- $hooks = array();
- // Logging level
- //$log_level = QUICKBOOKS_LOG_NORMAL;
- //$log_level = QUICKBOOKS_LOG_VERBOSE;
- $log_level = QUICKBOOKS_LOG_DEBUG;
- $soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN;
- $soap_options = array();
- $handler_options = array();
- $driver_options = array();
- $callback_options = array();
- $dsn = 'mysql://qb:<PASSWORD>@localhost/qb';
- /*
- Take the initialization part out
- if (!QuickBooks_Utilities::initialized($dsn))
- {
- QuickBooks_Utilities::initialize($dsn);
- QuickBooks_Utilities::createUser($dsn, $user, $pass);
- $Queue = new QuickBooks_Queue($dsn);
- $Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, 5);
- }
- */
- $server = new QuickBooks_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
- $response = $server->handle(true, true);
- ?>
- ## function that forms the QBXML
- ## placed in the Quickbooks.php
- class xml_build {
- function build_CustomerAdd ($_POST) {
- $xml = '<?xml version="1.0" encoding="utf-8"?>
- <?qbxml version="2.0"?>
- <QBXML>
- <QBXMLMsgsRq onError="stopOnError">
- <CustomerAddRq requestID="' . $requestID . '">
- <CustomerAdd>
- <Name>' . $_POST['firstname'] . ' ' . $_POST['lastname'] . '</Name>
- <CompanyName></CompanyName>
- <FirstName>' . $_POST['firstname'] . '</FirstName>
- <LastName>' . $_POST['lastname'] . '</LastName>
- <BillAddress>
- <Addr1>' . $_POST['address_1'] . '</Addr1>
- <Addr2>' . $_POST['address_2'] . '</Addr2>
- <City>' . $_POST['city'] . '</City>
- <State>' . $_POST['state'] . '</State>
- <PostalCode>' . $_POST['zip'] . '</PostalCode>
- <Country>United States</Country>
- </BillAddress>
- <Phone>' . $_POST['home_phone_1'] . '-' . $_POST['home_phone_2'] . '-' . $_POST['home_phone_3'] .'</Phone>
- <AltPhone>' . $_POST['cell_phone_1'] . '-' . $_POST['cell_phone_2'] . '-' . $_POST['cell_phone_3'] .'</AltPhone>
- <Fax></Fax>
- <Email>' . $_POST['email'] . '</Email>
- <Contact>' . $_POST['firstname'] . ' ' . $_POST['lastname'] . '</Contact>
- </CustomerAdd>
- </CustomerAddRq>
- </QBXMLMsgsRq>
- </QBXML>';
- return $xml;
- }
- }
- $xml_out = new xml_build;
- function _quickbooks_customer_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
- {
- $xml_out->buildCustomerAdd($_POST);
- }
- function _quickbooks_customer_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
- {
- }
Add Comment
Please, Sign In to add comment