I have successfully setup the Quickbooks PHP DevKit, but I am currently trying to run the example_customer_add script with my sandbox. When I do, I get the following error:
Notice: Undefined variable: Context in /Applications/MAMP/htdocs/quickbooks-php/test_qb.php on line 54
I've tried to track down the $Context variable, but it is used all over the place, and I'm unsure of where it being set, etc...
Any help is appreciated! Thanks!
EDIT
I'm just using the script included in the docs folder of the Quickbooks PHP DevKit:
<?php
require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/views/header.tpl.php';
?>
<pre>
<?php
$CustomerService = new QuickBooks_IPP_Service_Customer();
$Customer = new QuickBooks_IPP_Object_Customer();
$Customer->setTitle('Ms');
$Customer->setGivenName('Shannon');
$Customer->setMiddleName('B');
$Customer->setFamilyName('Palmer');
$Customer->setDisplayName('Shannon B Palmer ' . mt_rand(0, 1000));
// Terms (e.g. Net 30, etc.)
$Customer->setSalesTermRef(4);
// Phone #
$PrimaryPhone = new QuickBooks_IPP_Object_PrimaryPhone();
$PrimaryPhone->setFreeFormNumber('860-532-0089');
$Customer->setPrimaryPhone($PrimaryPhone);
// Mobile #
$Mobile = new QuickBooks_IPP_Object_Mobile();
$Mobile->setFreeFormNumber('860-532-0089');
$Customer->setMobile($Mobile);
// Fax #
$Fax = new QuickBooks_IPP_Object_Fax();
$Fax->setFreeFormNumber('860-532-0089');
$Customer->setFax($Fax);
// Bill address
$BillAddr = new QuickBooks_IPP_Object_BillAddr();
$BillAddr->setLine1('72 E Blue Grass Road');
$BillAddr->setLine2('Suite D');
$BillAddr->setCity('Mt Pleasant');
$BillAddr->setCountrySubDivisionCode('MI');
$BillAddr->setPostalCode('48858');
$Customer->setBillAddr($BillAddr);
// Email
$PrimaryEmailAddr = new QuickBooks_IPP_Object_PrimaryEmailAddr();
$Customer->setPrimaryEmailAddr($PrimaryEmailAddr);
if ($resp = $CustomerService->add($Context, $realm, $Customer))
{
print('Our new customer ID is: [' . $resp . '] (name "' . $Customer- >getDisplayName() . '")');
}
else
{
print($CustomerService->lastError($Context));
}
?>
</pre>
<?php
require_once dirname(__FILE__) . '/views/footer.tpl.php';
The quickbooks_oauth table looks like this after attempting to connect:
'1', 'DO_NOT_CHANGE_ME', '12345', 'qyprdaX1yo1uYqu3GU8xxPvs8raoTss2ZVRBE3fHWy7qZdAB', 'IWZHlW2e956sqR9GVIxa2JOU82NdSrJixZLpb3af', 'KNwiKE2bUXtqFqJ/Vb0NhjzBGYMXwRRcT9xtFOQiV6F8aEgUoqGzA7aheRLPJ/z6EPYy1ZS4e6ZuVpteBaQtxc5H0cN5VcCmWLfj+lryaCpLgw8mGK5+E/Muv2wJ+3UwbOyqVstU+pYQw/yNgFKhfSuA3lOgjgqctuO6ZpMK1wWr42IycA05QrJuOB4+LQ==', 'rCj1V3zl4Jj5mHgTw+BPCPN7SDcJkzLQPWb1tyerEXedsQB0WsZ+caMCBafS+hfN3ECZl3mfNDSyIqKDK+t8RSEAKyFWwRSPOh3UcWDCDEhXrTSUddmKhoIq6pL6yVtNEyETyNtfMaKYN+U6uIwSEMKZB/4IUjK8c0GP5KhoKSl0dv+Bp9w=', '1391140255', 'QBO', NULL, '2015-06-04 19:57:58', '2015-06-04 19:58:36', '2015-06-04 19:58:36'
The code you posted is missing several lines at the top of the script. Look at the example on GitHub:
https://github.com/consolibyte/quickbooks-php/blob/master/docs/partner_platform/example_app_ipp_v3/example_customer_add.php#L3
There are two require_once statements that you are missing. $Context is defined in those required files.
require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/views/header.tpl.php';
Fix your code so that you're using the example code completely, and making sure those required files actually get included.
If you continue to have trouble, please post your updated code.
You can see where $Context gets defined here:
https://github.com/consolibyte/quickbooks-php/blob/master/docs/partner_platform/example_app_ipp_v3/config.php#L110
Note that you must be connected to QuickBooks to run the example. I'm assuming you have clicked the "Connect to QuickBooks" button and gotten connected already... right?
Related
I've a few php files that need to access the Parse backend. I don't know how to connect them. In my previous question the answer was: SESSIONS!
Now i've a new problem:
If i comment out session_start(), i've access to the Parse database, but not to the session variables.
If i uncomment session_start(), i've access to Session variables, but not to Parse anymore.
Why is that?
<?PHP
//session_start();
echo "I'm in PHP!!!";
require 'vendor/autoload.php';
use Parse\ParseException;
use Parse\ParseClient;
use Parse\ParseQuery;
use Parse\ParseUser;
ParseClient::initialize('xxxxx', 'xxxxx', 'xxxxx');
ParseClient::setServerURL('https://xxxxxx');
//if (isset($_SESSION["currentUser"])){
$query = new ParseQuery("CourseInfo");
$query -> equalTo ("CourseID", "Demo2");
$results = $query->find();
echo "Successfully retrieved " . count($results) . " scores.";
// }
echo "Favorite color is " . $_SESSION["favcolor"] . ".<br>"; // just to test
if (isset($_SESSION["currentUser"])) {echo $_SESSION["currentUser"];}
?>
After calling the initialize method, add the following:
ParseClient::setStorage( new ParseSessionStorage() );
Also checkout: http://parseplatform.github.io/docs/php/guide/#session-storage-interface
I think your answer is right, a somewhat more detailed explanation is here:
New parse.com php API - currentUser not giving back a user
Tx
I'm trying to figure out where I'm going wrong with the below code to work with the Coinbase API. I have Composer installed with the Coinbase dependency. Previously I was getting an error that the Coinbase class was not installed, which I figured out was because of the path. I no longer get any error but the code is not executing. Can anyone help?
<?php
require_once __DIR__ . '/usr/bin/vendor/autoload.php';
use coinbase\coinbase;
//I've tried to run it both with and without the following 3 lines of code with no difference
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$apiKey = 'XXX';
$apiSecret = 'XXX';
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
$account = $client->getPrimaryAccount();
echo 'Account name: ' . $account->getName() . '<br>';
echo 'Account currency: ' . $account->getCurrency() . '<br>';
?>
Per the examples on the Coinbase repository, you've got a namespacing issue. PHP can't find the Configuration or Client classes.
<?php
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
at the top of your file will resolve it. After that, read http://php.net/manual/en/language.namespaces.basics.php and http://php.net/manual/en/language.namespaces.rationale.php.
I'm doing an integration with PHP my system, so I can launch sales in QuickBooks. To integrate'm using the API provided this link https://github.com/consolibyte/quickbooks-php.
Set everything as instructed, but the moment you throw a sale, I get the following error:
2020: [Required param missing, need to supply the required value for the API, Required parameter Line.DetailType is missing in the request]
The class that generates invoices is currently as follows:
<?php
require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/views/header.tpl.php';
?>
<pre>
<?php
$InvoiceService = new QuickBooks_IPP_Service_Invoice();
$Invoice = new QuickBooks_IPP_Object_Invoice();
$Invoice->setDocNumber('WEB' . mt_rand(0, 10000));
$Invoice->setTxnDate('2015-12-10');
$Line = new QuickBooks_IPP_Object_Line();
$Line->setDetailType('Example');
$Line->setAmount(12.95 * 2);
$Line->setDescription('Example');
$SalesItemLineDetail = new QuickBooks_IPP_Object_SalesItemLineDetail();
$SalesItemLineDetail->setItemRef('8');
$SalesItemLineDetail->setUnitPrice(12.95);
$SalesItemLineDetail->setQty(2);
$Line->addSalesItemLineDetail($SalesItemLineDetail);
$Invoice->addLine($Line);
$Invoice->setCustomerRef('67');
if ($resp = $InvoiceService->add($Context, $realm, $Invoice))
{
print('Our new Invoice ID is: [' . $resp . ']');
}
else
{
print($InvoiceService->lastError());
}
?>
</pre>
<?php
require_once dirname(__FILE__) . '/views/footer.tpl.php';
Someone has gone through this problem?
I really need help because they do not understand much about QuickBooks.
Thanks,
This error:
Required parameter Line.DetailType is missing in the request
Means you are missing a required parameter named Line.DetailType in your request. More specifically -- in your case, you're actually sending an invalid value for this parameter.
$Line->setDetailType('Example');
That ^^^ is not valid. Please take the time to refer to Intuit's documentation:
https://developer.intuit.com/docs/api/accounting/Invoice
And take the time to refer to the examples:
https://github.com/consolibyte/quickbooks-php/blob/master/docs/partner_platform/example_app_ipp_v3/example_invoice_add.php#L21
And notices that the documentation/examples show the correct value is:
// Set to SalesItemLineDetailfor this type of line.
$Line->setDetailType('SalesItemLineDetail');
Recently, I have updated my site using an SSL and all URIs are now "https://".
My site is developed with Symfony 2 and mixing a Wordpress installation inside Symfony 2 web/wordpress directory.
All regular access is fine. Only one question:
In my Symfony 2, there is this code snippet:
private function getRecentPosts($num = 4)
{
require_once 'wordpress/wp-includes/class-IXR.php';
$user = '11111';
$pwd = '22222';
$host='https://www.rsywx.net';
$script='/wordpress/xmlrpc.php';
$port=443;
$client = new \IXR_Client($host, $script, $port);
$params = array(0, $user, $pwd, $num);
$client->query('metaWeblog.getRecentPosts', $params);
$wp = $client->getResponse();
return $wp;
}
When my site is not wrapped with https, the above code works fine. But now it is under https, the above code is not working. If I dump the $client variable after the query function call, it gives an error like:
+error: IXR_Error {#256 ▼
+code: -32300
+message: "transport error - could not open socket"
Any hints? Do I need to tweak my WP?
The problem was on the file wp-includes/class-IXR.php, it doesn't work with HTTPS, you must use also class-wp-http-ixr-client.php . And don't forget to include the configuration file wp-load.php.
The code snippet will be:
private function getRecentPosts($num = 4)
{
include 'wordpress/wp-load.php';
require_once ABSPATH . WPINC . 'wordpress/wp-includes/class-IXR.php';
require_once ABSPATH . WPINC . 'wordpress/wp-includes/class-wp-http-ixr-client.php';
$user = '11111';
$pwd = '22222';
//Deprecated
/*
$host='https://www.rsywx.net';
$script='/wordpress/xmlrpc.php';
$port=443;
$client = new \IXR_Client($host, $script, $port);
*/
$client = new WP_HTTP_IXR_CLIENT('https://www.rsywx.net/wordpress/xmlrpc.php');
$params = array(0, $user, $pwd, $num);
$client->query('metaWeblog.getRecentPosts', $params);
$wp = $client->getResponse();
return $wp;
}
I just avoided using XMLRPC at all to solve this.
In my Symfony 2 application, I just used a 2nd database to directly access the underlying wordpress database. It is a hack but it resolves my issue for the time being.
I am working on the tutorial on IBM.com for using the Zend framework to work with the Google Calendar API. I literally copied a chunk of code from the tutorial and tried to use it, but it does not seem to be working. My php file includes the following:
<!--Some HTML is above here-->
<body>
<?php
// load library
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
Zend_Loader::loadClass('Zend_Http_Client');
// create authenticated HTTP client for Calendar service
$gcal = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$user = "username#gmail.com"; //replace with my username
$pass = "pass"; //replace with my password
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $gcal);
$gcal = new Zend_Gdata_Calendar($client);
// generate query to get event list
$query = $gcal->newEventQuery();
$query->setUser('default');
$query->setVisibility('private');
$query->setProjection('basic');
// get and parse calendar feed
// print output
try {
echo "<!--this comment is seen-->\n";
$feed = $gcal->getCalendarEventFeed($query);
echo "<!--this comment is not seen-->\n";
} catch (Zend_Gdata_App_Exception $e) {
//this doesn't happen.
echo "Error: " . $e->getResponse();
}
?>
<h1><?php echo $feed->title; ?></h1>
<?php echo $feed->totalResults; ?> event(s) found.
<p/>
<ol>
</body>
Literally the only changes I made to this code is replacing the username and password with my own email address and password. When the code execution reaches the statement in the try block, it seems to fail, but is not caught in the catch block, even when I change it to catch any exception, not just Zend_Gdata_App_Exception. The generated page source clearly shows that the PHP is crashing, though:
<!--Some HTML is above here-->
<body>
<!--this comment is seen-->
with nothing after that. I am learning PHP on the fly here, so any help would be extremely appreciated!
<?php
**$path = 'ZendGdata/library';
$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $path);**
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
...
and you should download the ZendGdata/library like they explain here https://developers.google.com/google-apps/calendar/v1/developers_guide_php
that is the official google calendar api Developer's Guide. The code you are using is deprecated though. I'm still using it but they suggest you switch over to google calendar API v3, you can find the documentation for that, on the same page.