本文整理汇总了PHP中QuickBooks_Utilities::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP QuickBooks_Utilities::initialize方法的具体用法?PHP QuickBooks_Utilities::initialize怎么用?PHP QuickBooks_Utilities::initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QuickBooks_Utilities
的用法示例。
在下文中一共展示了QuickBooks_Utilities::initialize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_index
/**
* Houses the instance of the soap server and creates the mappings for errors, function callbacks
* @author Jayson Lindsley <jay.lindsley@gmail.com>
*/
public function action_index()
{
//Username and password used for the web connector, QWC file, and the QB Framework
$user = 'QBAPI Username';
$pass = 'QBAPI Password';
//Configure the logging level
$log_level = QUICKBOOKS_LOG_DEVELOP;
//Pure-PHP SOAP server
$soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN;
//we can turn this off
$handler_options = array('deny_concurrent_logins' => false, 'deny_reallyfast_logins' => false);
// The next three params $map, $errmap, and $hooks are callbacks which
// will be called when certain actions/events/requests/responses occur within
// the framework
// Maps inbound requests to functions
$map = array(QUICKBOOKS_ADD_CUSTOMER => array(array($this, '_quickbooks_customer_add_request'), array($this, '_quickbooks_customer_add_response')), QUICKBOOKS_MOD_CUSTOMER => array(array($this, '_quickbooks_customer_mod_request'), array($this, '_quickbooks_customer_mod_response')));
//Map error handling to functions
$errmap = array(3070 => array($this, '_quickbooks_error_stringtoolong'), 3140 => array($this, '_quickbooks_reference_error'), '*' => array($this, '_quickbooks_error_handler'));
//Login success callback
$hooks = array(QuickBooks_WebConnector_Handlers::HOOK_LOGINSUCCESS => array(array($this, '_quickbooks_hook_loginsuccess')));
//MySQL database name containing the QuickBooks tables is named 'quickbooks' (if the tables don't exist, they'll be created for you)
$dsn = 'mysql://username:password@host/databasename';
QuickBooks_WebConnector_Queue_Singleton::initialize($dsn);
if (!QuickBooks_Utilities::initialized($dsn)) {
// Initialize creates the neccessary database schema for queueing up requests and logging
QuickBooks_Utilities::initialize($dsn);
// This creates a username and password which is used by the Web Connector to authenticate
QuickBooks_Utilities::createUser($dsn, $user, $pass);
// Initial test case customer
$primary_key_of_new_customer = 512;
// Fire up the Queue
$Queue = new QuickBooks_WebConnector_Queue($dsn);
// Drop the directive and the customer into the queue
$Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, $primary_key_of_new_customer);
// Also note the that ->enqueue() method supports some other parameters:
// string $action The type of action to queue up
// mixed $ident = null Pass in the unique primary key of your record here, so you can pull the data from your application to build a qbXML request in your request handler
// $priority = 0 You can assign priorities to requests, higher priorities get run first
// $extra = null Any extra data you want to pass to the request/response handler
// $user = null If you're using multiple usernames, you can pass the username of the user to queue this up for here
// $qbxml = null
// $replace = true
}
//To be used with singleton queue
$driver_options = array();
//Callback options, not needed at the moment
$callback_options = array();
//nothing needed here at the moment
$soap_options = array();
//construct a new instance of the web connector server
$Server = new QuickBooks_WebConnector_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
//instruct server to handle responses
$response = $Server->handle(true, true);
}
示例2: dirname
if (!QuickBooks_Utilities::initialized($api_driver_dsn)) {
// Create the example tables
$file = dirname(__FILE__) . '/example.sql';
if (file_exists($file)) {
$contents = file_get_contents($file);
foreach (explode(';', $contents) as $sql) {
if (!trim($sql)) {
continue;
}
mysql_query($sql) or die(trigger_error(mysql_error()));
}
} else {
die('Could not locate "./example.sql" to create the demo SQL schema!');
}
//
QuickBooks_Utilities::initialize($api_driver_dsn);
// This
QuickBooks_Utilities::createUser($api_driver_dsn, $user, $pass);
}
//
$API = new QuickBooks_API($api_driver_dsn, $user, $source_type, $source_dsn, $api_options, $source_options, $driver_options);
// Get the complete list of "Customers" from QuickBooks
//
// Unfortunately, non-US versions of QuickBooks do not yet support the use of
// "iterators" to break up the response from QuickBooks into many smaller
// chunks. So, if we ask for the complete customer list, the response is so
// large that the transfer takes a long time, the Web Connector times out, or
// the HTTP server throws an error after receiving to much data.
//
// Thus, instead of sending just a single request, we're going to fetch the
// list of customers by date range instead.
示例3: SUBSTRING
$CustomerID AS ListObjID,
ordbillemail AS DataExtValue
FROM
isc_orders
WHERE
orderid = SUBSTRING($CustomerID, 3) AND
$CustomerID LIKE \'O:%\'
) '), 'orderitem_additional_queries' => array(0 => '
SELECT
ordershipmodule AS ShipMethodID,
(ordhandlingcost + ordshipcost) AS Amount,
CONCAT(\'Shipping and Handling: \', ordshipmethod) AS Descrip,
\'' . QUICKBOOKS_NONTAXABLE . '\' AS SalesTaxCodeName
FROM
isc_orders
WHERE
orderid = $OrderID', 1 => '
SELECT
CONCAT(\'Billing phone number: \', ordbillphone, \', Shipping phone number: \', ordshipphone) AS Descrip
FROM
isc_orders
WHERE
orderid = $OrderID '));
$callback_options = array();
if (!QuickBooks_Utilities::initialized($dsn)) {
QuickBooks_Utilities::initialize($dsn);
QuickBooks_Utilities::createUser($dsn, $user, $pass);
}
//
$Server = new QuickBooks_Server_Integrator_Interspire($dsn, $integrator_dsn, $alert, $user, $map, $onerror, $hooks, $log_level, $soap, $wsdl, $soap_options, $handler_options, $driver_options, $api_options, $source_options, $integrator_options, $callback_options);
$Server->handle(true, true);
示例4: set_time_limit
set_time_limit(0);
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/Users/kpalmer/Projects/QuickBooks');
require_once 'QuickBooks.php';
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('America/New_York');
}
$username = 'quickbooks';
$password = 'password';
error_reporting(E_ALL);
ini_set('display_errors', 1);
//rint(wtaf');
$dsn = 'mysql://root:s4p3rs3c4r3@localhost/quickbooksWIP2';
if (!QuickBooks_Utilities::initialized($dsn)) {
header('Content-Type: text/plain');
$driver_options = array();
$init_options = array('quickbooks_sql_enabled' => true);
QuickBooks_Utilities::initialize($dsn, $driver_options, $init_options);
QuickBooks_Utilities::createUser($dsn, $username, $password);
exit;
}
$mode = QUICKBOOKS_SERVER_SQL_MODE_READONLY;
//$mode = QUICKBOOKS_SERVER_SQL_MODE_WRITEONLY;
//$mode = QUICKBOOKS_SERVER_SQL_MODE_READWRITE;
//Delete Modes -- Remove or Flag?
//$deleteMode = QUICKBOOKS_SERVER_SQL_ON_DELETE_FLAG;
$deleteMode = QUICKBOOKS_SERVER_SQL_ON_DELETE_REMOVE;
// $dsn_or_conn, $how_often, $mode, $conflicts, $users = null,
// $map = array(), $onerror = array(), $hooks = array(), $log_level, $soap = QUICKBOOKS_SOAPSERVER_BUILTIN, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array()
$server = new QuickBooks_Server_SQL($dsn, '1 minute', $mode, $deleteMode, QUICKBOOKS_SERVER_SQL_CONFLICT_NEWER, $username, array(), array(), array(), QUICKBOOKS_LOG_DEVELOP, QUICKBOOKS_SOAPSERVER_PHP, QUICKBOOKS_WSDL);
$server->handle(true, true);
示例5: array
*/
require_once 'QuickBooks.php';
//
$dsn_or_conn = 'mysql://root:root@localhost/quickbooks_oscommerce';
//
$integrator_dsn_or_conn = 'mysql://root:root@localhost/quickbooks_oscommerce';
$user = 'oscommerce';
$pass = 'password';
$alert = 'keith@ConsoliBYTE.com';
$map = array();
$onerror = array();
$hooks = array();
$log_level = QUICKBOOKS_LOG_DEVELOP;
$soap = QUICKBOOKS_SOAPSERVER_BUILTIN;
$wsdl = QUICKBOOKS_WSDL;
$soap_options = array();
$handler_options = array();
$driver_options = array();
$api_options = array();
$source_options = array();
//
$integrator_options = array('product_defaults' => array('SalesOrPurchase_AccountName' => 'Other Income'), 'push_orders_as' => QUICKBOOKS_OBJECT_SALESRECEIPT);
$callback_options = array();
if (!QuickBooks_Utilities::initialized($dsn_or_conn)) {
QuickBooks_Utilities::initialize($dsn_or_conn);
QuickBooks_Utilities::createUser($dsn_or_conn, $user, $pass);
}
//QuickBooks_Utilities::createUser($dsn_or_conn, $user, $pass);
//
$Server = new QuickBooks_Server_Integrator_OSCommerce($dsn_or_conn, $integrator_dsn_or_conn, $alert, $user, $map, $onerror, $hooks, $log_level, $soap, $wsdl, $soap_options, $handler_options, $driver_options, $api_options, $source_options, $integrator_options, $callback_options);
$Server->handle(true, true);
示例6: qbwc
/**
* SOAP endpoint for the Web Connector to connect to
*/
public function qbwc()
{
$user = $this->config->item('quickbooks_user');
$pass = $this->config->item('quickbooks_pass');
// Memory limit
ini_set('memory_limit', $this->config->item('quickbooks_memorylimit'));
// We need to make sure the correct timezone is set, or some PHP installations will complain
if (function_exists('date_default_timezone_set')) {
// * MAKE SURE YOU SET THIS TO THE CORRECT TIMEZONE! *
// List of valid timezones is here: http://us3.php.net/manual/en/timezones.php
date_default_timezone_set($this->config->item('quickbooks_tz'));
}
// Map QuickBooks actions to handler functions
$map = array(QUICKBOOKS_ADD_CUSTOMER => array(array($this, '_addCustomerRequest'), array($this, '_addCustomerResponse')));
// Catch all errors that QuickBooks throws with this function
$errmap = array('*' => array($this, '_catchallErrors'));
// Call this method whenever the Web Connector connects
$hooks = array();
// An array of callback options
$callback_options = array();
// Logging level
$log_level = $this->config->item('quickbooks_loglevel');
// What SOAP server you're using
//$soapserver = QUICKBOOKS_SOAPSERVER_PHP; // The PHP SOAP extension, see: www.php.net/soap
$soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN;
// A pure-PHP SOAP server (no PHP ext/soap extension required, also makes debugging easier)
$soap_options = array();
$handler_options = array('deny_concurrent_logins' => false, 'deny_reallyfast_logins' => false);
// See the comments in the QuickBooks/Server/Handlers.php file
$driver_options = array('max_log_history' => 32000, 'max_queue_history' => 1024);
// Build the database connection string
$dsn = 'mysql://' . $this->db->username . ':' . $this->db->password . '@' . $this->db->hostname . '/' . $this->db->database;
// Check to make sure our database is set up
if (!QuickBooks_Utilities::initialized($dsn)) {
// Initialize creates the neccessary database schema for queueing up requests and logging
QuickBooks_Utilities::initialize($dsn);
// This creates a username and password which is used by the Web Connector to authenticate
QuickBooks_Utilities::createUser($dsn, $user, $pass);
}
// Set up our queue singleton
QuickBooks_WebConnector_Queue_Singleton::initialize($dsn);
// Create a new server and tell it to handle the requests
// __construct($dsn_or_conn, $map, $errmap = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_PHP, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array(), $callback_options = array()
$Server = new QuickBooks_WebConnector_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
$response = $Server->handle(true, true);
}