Pearce at Intuit (maker of QuickBooks) thought a better example was necessary--better than the 8MB of sample PHP code on Intuit's site. His example is great in that it's tiny--the minimum needed for "hello world." Unfortunately, his example doesn't work, either, or at least it doesn't anymore. It's still a great example overall, though, because it's small enough that I could debug it and get it working.
Below is my truly working code. However, both my code and Pearce's is only for example purposes. Amongst other issues, there are security issues with it. I left Pearce's ReadMe and comments largely intact; he talks to some extent about what you'd need in production.
Two sets of ingredients:
First, various Intuit account / security stuff:
Second, code stuff:
In the SDK root, change sdk.confg so that baseURL looks like the following; the CDATA stuff--begin and end tag--are for XHTML compliance. Do NOT add that to the sdk.config file. You're adding exactly 16 non-whitespace characters.
# apt-get update
THEN, add the line
# apt-get install libpcre3 libpcre3-dev
# pecl install oauth
extension=oauth.so
to
/etc/php5/apache2/php.ini
Restart apache after modifying php.ini.
The above is said to have worked in Ubuntu 12.04. I did it in Ubuntu 14.04 LTS.
Below this code in index.php:
Add this:
if (0) { // turn off if dup
$customer = new IPPCustomer();
$customer->DisplayName = "Eleven";
$dataService->add($customer);
}
You have to turn 0 to 1. Then, after listing 10 customers, the code will add customer "Eleven." I would guess you can add "11," but I did not care to find out at that point.
Note that if you try to add a duplicate customer, you'll get
I do not know yet how to properly handle the duplicate situation.
Here's all the things that wrong if you try to run Pearce's code by itself.
Warning: session_start(): open(/var/www/temp/sess_..., O_RDWR) failed: No such file or directory (2) in config.php on line 7
Solution: set your session_save_path('/var/www/temp');
to a directory that exists and that Apache has access to (and, eventually, is secure)
If you see a Session warning above you need to run the command: 'chmod 777 temp' in the terminal on the code page.
Solution: Well, more specifically, you need to set 777 permission for whatever you set session_save_path() to.
Set the consumer key and secret in the config.php file before you run this example
Solution: In config.php, as described above.
Warning: require_once(../v3-php-sdk-2.0.1/config.php): failed to open stream: No such file or directory in index.php on line 29
Solution:
require_once(PATH_SDK_ROOT . 'config.php');
in config.phprequire_once('../v3-php-sdk-2.0.1/config.php');
in index.phpWarning: Cannot modify header information - headers already sent by (output started at config.php:9) in oauth.php on line 27
Comment out echo "<h4>If you see a Session warning [...]
in config.php
GET https://appcenter.intuit.com/trackapi/TrackingActions [...] results in a 403 Forbidden error in the Chrome Developer Tools Network console (or equivalent).
Replace that URL, in index.php, with
https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere-1.3.1.js
I started with the file v3-php-sdk-2.0.5.zip. (Note that I made changes as described above.)
That was posted roughly in early 2014--"a year ago" as of 2015/Jan.
Please copy the code and documentation (including this page's content). Give me credit and / or blame. Also note that the code I started from is under the MIT License, as stated in the license.txt file.