Saturday, February 4, 2012

How to use Keith Palmer's PHP-DevKit to integrate a web app with Quickbooks Online

So here at Appguppy, we've been trying to enhance our e-commerce features to make it easier for our customers to sell stuff on their apps.  One of the initiatives is to integrate our system with Quickbooks so that people can easily pull in their products and sell the through their app.

For this we needed to use Intuit's Partner Platform and their SDK.  Unfortunately, they don't have a set of libraries for PHP, but since the IPP now allows oauth and XML, it is not too hard to integrate.  Still, there are dozens of object types and thousands of properties that we need to build in, and that's very time consuming.

So along comes a new version of Keith Palmer's excellent PHP-DevKit. Which finally supports oauth. The problem is, it's not immediately obvious how to use it.  Below is a step by step guide:

1. Download the latest devkit build. Unfortunately, its currently only available via SVN, so you'll have to install an SVN client and point it to this url:

svn checkout https://code.intuit.com/svn/repos/php_devkit
 
2.To create our simple app, we put it on a test server in our /var/www directory.  You should now have a file Quickbooks.php and a sub-directory Quickbooks under /var/www

3. Make sure you have mcrypt installed in PHP, you can check this with phpinfo().  If not, download and install it.

4. Make a new file index.php and put the following in the file:

require_once 'QuickBooks.php';


$token = 'sfewtw4et3w45sfsfsdfdsf';
$oauth_consumer_key = 'sfewtwsetsgsdsdfsdc';
$oauth_consumer_secret = 'dsffwe5tr4w5sdfsdfsdfsdfsdf';

// This is the URL of your OAuth auth handler page
$this_url = 'http://myserver/index.php';

// This is the URL to forward the user to after they have connected to IPP/IDS via OAuth
$that_url = 'http://myserver/other.php';

$dsn = 'mysql://test:test@localhost/quickbooks';

// You should set this to an encryption key specific to your app
$encryption_key = 'abcd1234';

// The user that's logged in
$the_username = 'your_app_username_here_2';

// The tenant that user is accessing within your own app
$the_tenant = 12345; 
if (!QuickBooks_Utilities::initialized($dsn))
  {
    // Initialize creates the neccessary database schema for queueing up requests and logging
    QuickBooks_Utilities::initialize($dsn);
  }

$IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere($dsn, $encryption_key, $oauth_consumer_key, $oauth_consumer_secret, $this_url, $that_url);

if ($IntuitAnywhere->handle($the_username, $the_tenant))
  {
    ; // The user has been connected, and will be redirected to $that_url automatically. 
  }
else
  {
    die('Oh no, something bad happened: ' . $IntuitAnywhere->errorNumber() . ': ' . $IntuitAnywhere->errorMessage());
  } 
  
Let's also make a file called other.php

require_once 'QuickBooks.php';


$token = 'sfewtw4et3w45sfsfsdfdsf';
$oauth_consumer_key = 'sfewtwsetsgsdsdfsdc';
$oauth_consumer_secret = 'dsffwe5tr4w5sdfsdfsdfsdfsdf';

// This is the URL of your OAuth auth handler page
$this_url = 'http://myserver/index.php';

// This is the URL to forward the user to after they have connected to IPP/IDS via OAuth
$that_url = 'http://myserver/other.php';

$dsn = 'mysql://test:test@localhost/quickbooks';

// You should set this to an encryption key specific to your app
$encryption_key = 'abcd1234';

// The user that's logged in
$the_username = 'your_app_username_here_2';

// The tenant that user is accessing within your own app
$the_tenant = 12345; 
if (!QuickBooks_Utilities::initialized($dsn))
  {
    // Initialize creates the neccessary database schema for queueing up requests and logging
    QuickBooks_Utilities::initialize($dsn);
  } 
 
// Set up the IPP instance                                                                                                                                                                                                    
$IPP = new QuickBooks_IPP($dsn);

// Set up our IntuitAnywhere instance                                                                                                                                                                                         
$IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere($dsn, $encryption_key, $oauth_consumer_key, $oauth_consumer_secret);

// Get our OAuth credentials from the database                                                                                                                                                                                
$creds = $IntuitAnywhere->load($the_username, $the_tenant);

// Tell the framework to load some data from the OAuth store                                                                                                                                                                  
$IPP->authMode(
               QuickBooks_IPP::AUTHMODE_OAUTH,
               $the_username,
               $creds);

// Print the credentials we're using                                                                                                                                                                                          
print_r($creds);

// This is our current realm                                                                                                                                                                                                  
$realm = $creds['qb_realm'];

// Load the OAuth information from the database                                                                                                                                                                               
if ($Context = $IPP->context())
  {
    // Set the DBID                                                                                                                                                                                                           
    $IPP->dbid($Context, 'something');

    // Set the IPP flavor                                                                                                                                                                                                     
    $IPP->flavor($creds['qb_flavor']);

    // Get the base URL if it's QBO                                                                                                                                                                                           
    if ($creds['qb_flavor'] == QuickBooks_IPP_IDS::FLAVOR_ONLINE)
      {
        $IPP->baseURL($IPP->getBaseURL($Context, $realm));
      }

    print('Base URL is [' . $IPP->baseURL() . ']' . "\n\n");
     $CustomerService = new QuickBooks_IPP_Service_Customer();

    $perpage = 3;
    for ($page = 1; $page <= 3; $page++)
      {
        print('PAGE ' . $page . "\n\n");

        $list = $CustomerService->findAll($Context, $realm, null, null, $page, $perpage);

        foreach ($list as $Customer)
          {
            print('Name [' . $Customer->getName() . ']' . "\n\n");
          }

        print("\n\n\n");
      }

    print("\n\n\n\n");
    print('Request [' . $IPP->lastRequest() . ']');
    print("\n\n\n\n");
    print('Response [' . $IPP->lastResponse() . ']');
    print("\n\n\n\n");
  }
else
  {
    die('Unable to load a context...?');
  }
 

5. Now, a little aside on how oauth works with PHP-DevKit -
  • The first request is made by the original php page (in our case index.php - but you can specify whatever you want in $this_url) to the oauth server with your oauth consumer secret and and oauth consumer key (I'll tell you how to get those in a sec).  This is done by the handle() function in the IntuitAnywhere object.
  • The handle() function then redirects the user to the authentication URL, which shows one of those login/connect screens to the user (like you see when you use a Twitter app).  
  • Once the user accepts the app, Intuit sends the user back to the page they were on (it will return to whatever is in $this_url -- in our case index.php).  This time the handle() function sees that there is a token in the HTTP request and saves the token.  It then redirects the user to another page ($that_url, or in our case other.php).
  • In other.php, we re-initialize the IntuitAnywhere object, but instead of using handle() to get the token, we use load() to load the token that was saved in the previous step.
  • We then create an IPP object specifying that we're using oauth, and that will provide us with a context from which to make calls.
6. Now let's make this thing work.  First, get your token, oauth consumer key and oauth consumer secret from Intuit's Developer Center under Manage Apps -> (click on your Dev Master app) -> "App Tokens and Keys".  In both index.php and other.php set the lines marked in purple above to those values.

7. Replace myserver (marked in green) in both files to your server URL.   Also update the Mysql username and password (marked in blue) to yours

8. Create a database in mysql called quickbooks. This will be used to save tokens.  All the tables will be created automatically by PHP Devkit.

9. That's it - now point your browser to http://myserver/index.php - it should redirect to the Intuit Anywhere authorization screen. Users can enter their username and password there and click to authorize your app. Once they do, it will go to other.php and you should see a list of customers for that user.

Hopefully this makes oauth with devkit a bit easier to get started.

Monday, January 30, 2012

How to setup FreeRDP from Linux (Ubuntu) to Windows 7

This one's for all those tech geeks out there...

There's finally a working solution to use RemoteApp from Windows - that means you can finally have a RELIABLE seamless desktop with a remote Windows PC on you linux machine.

First off: why do this?

I was using VirtualBox with their great seamless mode for a while with Ubuntu, but it was never really stable. After a few hours it would crash every time. When it was running, it ran well. But it never worked for very long.

The xFreeRDP solution lets you connect to a remote computer and use windows programs seamlessly with Microsoft's RemoteApp (which is built in to Win7, Vista, Server)


How...

1. Make sure you have Windows 7 ENTERPRISE or ULTIMATE or Windows Server.  This won't work on Windows 7 Pro.

2. Download the latest version of FreeRDP from here: https://github.com/FreeRDP/FreeRDP

3. Setup your system for compiling it - on Ubuntu you need to do the following:

$ sudo apt-get install build-essential git-core cmake libssl-dev libx11-dev libxext-dev libxinerama-dev libxcursor-dev libxdamage-dev libxv-dev libxkbfile-dev libasound2-dev libcups2-dev

$ sudo apt-get install libavutil-dev libavcodec-dev 

$ cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_SSE2=ON .

$ make

$ sudo make install

$ sudo cat > /etc/ld.so.conf.d/freerdp.conf 
/usr/local/lib/freerdp
/usr/local/lib

$ ldconfig


4. On your Windows 7 machine, run Regedit and under HKLocalMachine\SOFTWARE\Policies\Microsoft\Windows NT add a key named "Terminal Services"

5. Under that, add a DWORD32 value named "fAllowUnlistedRemotePrograms" and set the value to 1

If you don't do this, you will get the following error: RAIL exec error: execResult=RAIL_EXEC_E_NOT_IN_ALLOWLIST NtError=0x15


6. run the following command on your Linux box


$ xfreerdp -u <username>  --app --plugin ./usr/local/lib/freerdp/rail.so --data "%windir%\system32\cmd.exe" -- <ip of your windows machine>

Note your rail.so path may be different, so you may have to search for it.

That's it... you can now launch programs from the cmd shell.

Monday, January 16, 2012

Could SoLoMo Be the Key to Powering Your Mobile Strategy?

The most recent buzz on mobile is that branded mobile apps could be the most powerful form of advertising yet, specifically because they relay a company’s message in a much more active way than just print ads or websites. In fact, downloading a mobile app that is informational or provides a specific utility has been shown to engage consumers even more than entertainment or gaming. How? The answer could be SoLoMo.

Broadly speaking, SoLoMo refers to the new generation of technologies that integrate social media (network content and shareability), local (location-based technologies such as GPS and real-time activity) and mobile (smartphones capabilities that render technology useable anytime, anywhere).
  
So what are we talking here?  Sending your customers push notifications on special deals or coupons when they happen to be in your neighborhood?  It may not be as complicated as that. 

If you’re thinking of creating a branded mobile app for your company, consider SoLoMo as a way to devise your mobile strategy. 

For instance, if you’re a retailer, you may already be using social media channels such as Facebook, Twitter and Youtube.  You probably also have your own blog. So consider integrating these as a tab into your app, to offer your customers valuable content in the form of tips and hints to help them find the product they’re looking for and attain a more satisfying shopping experience when they’re in your store. 

If you’re a food truck, take a hint from the “Lo” or SoLoMo and integrate a geo-location tab in your mobile app that helps your customers find you whether you’re at your usual haunt or may be venturing out to a new neighborhood.   Your customers will love being able to have instant access to your location when they’re in the mood for some food. 

And finally, the “Mo” of SoLoMo could just be the key to attaining discoverability for your mobile app.  Text message is one of the integral features of phones that capitalizes on being able to connect with consumers anytime, anywhere.  Consider using one of the popular DIY mobile app creation tools out there to create a mobile app that can be sent out to customers via text message links. 

No, SoLoMo isn’t a tropical locale that you can score a trip to via TravelZoo. But it could just be your road to devising a mobile app that generates that extra level of interactivity with your customers and lands you your next sale!

Sunday, November 20, 2011

Why app stores may be restricting too much of your freedom

Here at Appguppy, we’re often asked where the mobile apps that you create actually live, since they’re not distributed through the app stores.  Our answer?  We’ll we don’t just have one response, we’ve got six: Facebook, Twitter, QR codes, text message, email AND your website.  Technically speaking, it would be most accurate to say that the apps lives in our secure servers, or Appguppy’s cloud.  But since the apps get distributed through these 6 different methodologies, in a sense, they’re living in social media.  But what does it mean for your app if it isn’t being deployed through the stores?  More trouble than you asked for.  Lets find out why:    

1)  Mobile app stores are too restrictive:  Let’s take a look at some of the terms you’ve got to be familiar with if you want your app to wind up in a store -- licensing, certificates, compilation...the list goes on.   Maybe you’re thinking you could rely on another entity, perhaps a company, to submit the app for you.  Unfortunately, even paying that company the big bucks doesn’t guarantee that your app will make it into the stores.  That’s because stores are constantly changing their restrictions, making it more and more difficult day by day, to make it in.  

2)  Mobile app stores take time:  What’s the minimum amount of time that your app will be ready for download by your customers once you submit it?  When it comes the Apple app store, you could be waiting as much as a week.  But what if you’re trying to generate interest in a special promotion you’re having right now or get more people out to your event while it’s still happening?  Unfortunately, the stores can’t help you out there.  

3)  Mobile app stores don’t give you discoverability:  So you get your app into the store, now what?  Chances are, you’ll be competing with hundreds of thousands of other apps for the attention of consumers. So on top of worrying about SEO optimization, you’ve got to be worrying about app discoverability in the stores?  At Appguppy, we don’t think you should have to deal with all of that extra hassle.  Our idea is that you should be able to distribute that app directly to your customers’ phones, harnessing the power of all of your Twitter followers or all of your Facebook likes.  

At Appguppy, we believe you shouldn’t have to struggle with all of the time, money and complexity currently involved in distributing apps through stores.  That’s our ultimate source of inspiration.  It’s also our solution to helping to make sure that your apps work on all smartphones, on all platforms.  So while we may be saying “Saynora!” to the stores, we know we’re saying “Bring it on!” to freedom. 

Thursday, November 3, 2011

Will generation "mobile" give way to generation "app"?

Generation Mobile: strong majority of Gen X & Gen Y now own smartphones, what’s your strategy?

The kids are alright…with their smartphones that is. Nielsen survey results reported in the New York Times showed 62% market penetration for smartphones among adults aged 25-34. This is a staggering figure, indicative of an entire segment of society that is moving towards mass adoption of mobile computing. The article we linked to quotes a senior Nielsen executive on his opinion that the recently published figures should serve as a wake-up call to advertisers who have been waiting for some sort of “tipping point” before moving into mobile media and advertising.

Those are wise words and we recommend you take note.

The mobile e-commerce market is estimated to reach $119 billion by 2015. If you’ve ever wondered what’s fueling that growth, take a look at the figures we keep publishing on this blog. 62% of an entire generation leapt into mobile computing within less than 5 years. Smartphone usage is growing even amongst adults in the 44+ market. Today’s tweens and teens will reach adulthood with the expectation of owning a smartphone as soon as is financially feasible for them to do so.

Which means that within the next few years, the majority of adults from 18-40 will come to expect a mobile experience from any organization they interact with, including yours. Don’t believe us? Think back to 10 or 15 years ago. We’re actually old enough to remember when having a website was an option rather than a requirement. Then five years later, everyone was mulling over whether they really needed to move into social media and other web 2.0 technologies. Today these aren’t even questions. Consumers will grow to expect mobile connections the same way they grew to expect websites, Facebook, Twitter and blogs.

The Appguppy platform offers the first democratic opportunity for ordinary people, well, ordinary passionate people, to set the standard in meeting the growing demand for to provide consumers, fans and followers with direct mobile connections. Apps built through our platform can function as an extension of your overall business strategy, helping you to deliver news, unique content and e-commerce to forge a closer relationship with your app downloaders through whichever smartphone platform they prefer.

Here’s another fun fact for you. Mobile tablets are so ubiquitous that customers are crashing hotel wi-fi while cruising the internet on free connections. Wouldn’t you rather they be browsing your app?

Sign up for an Appguppy app here!

Saturday, October 29, 2011

RIM is down but not out --Why you need a blackberry mobile app

Life’s been rocky for Research in Motion (RIM) in recent years. The Canadian telecommunications giant that once possessed a rock-solid hold over the smartphone market has seen its brand equity and market penetration significantly diminished by the release of Apple’s iPhone and Google’s Android platform.

Along with dwindling profits comes a decreased mobile cultural presence. With its lightning fast product lifecycles, the world of tech practically functions in dog years. Six months constitutes half a decade in this land. Which is how Blackberry, the smartphone that once inspired its own cultish legion of “Crackberry” devotees, has fallen from grace to become the bĂȘte noire of mobile computing.

When we tell people that the Appguppy platform develops mobile apps that work on iPhone, Android AND Blackberry, we usually get an earful about how RIM doesn’t matter anymore or raised eyebrows over why our genius co-founder bothered to write all those lines of specialized code to make sure your customized mobile app would work on Blackberry.

Discounting RIM is both shortsighted and misguided. If you want to go mobile, you need a multi-platform app strategy. And that must include Blackberry. Because what we all know and love about tech is that a speedy comeback is as probable as a tumble off the fanboy pedestal. The good news is that our instincts about Blackberry proved right on the money. Recently, several news outlets made our day when they reported that RIM is rapidly outselling Apple’s iPhone in India.

It comes down to this. We’re the first and only mobile app development software out there that lets you take your business anywhere, and to anyone, through mobile.

Have you ever wanted to take your business to a large market like India? Thanks to Appguppy, you can. By signing up with us, you have a much better chance of reaching 602 million Indian mobile subscribers and potential customers on a Blackberry than you would on an iPhone.

Having your app work on Blackberry starts sounding better all the time, doesn’t it?

Friday, October 14, 2011

4 ways to generate leads with your mobile app

You hear about them everywhere: Mobile apps are the hottest thing, and it seems like every big company has created its own.  Pizza Hut created one that lets its customers order pizza. BestBuy created one that alerts customers about the latest promotions. With a well designed app from Appguppy, your business can achieve a significant ROI by turning one-time sales into long-term relationships.  So how does a mobile app build customer relationships?

Having a mobile app for your business really can help build stronger relationships.  Because apps are fun and interactive, customers often don’t even realize that they are being marketed to.  Apps can mix marketing messages with other interactive content, and marketing messages sent via apps don’t get junked or sent to trash like email.  Moreover, using an app to market provides immediacy: you can distribute your message to your customers, regardless of where they may be, and they can communicate with you as well. The more difficult part is learning to take full advantage of the power of your app.  Becoming proficient at this requires time and planning, but it can be a lot easier if you follow these rules:
  1. Your app should be user-centered, not marketing-centered. The app should provide real functionality for the benefit of its users first, and marketing functionality second.  An example is adding an e-commerce functionality to your app that lets users purchase your products or services on the go.
  2. Your app should facilitate communication.  Users should feel that the app provides as much opportunity for them to speak to you as it does for you to speak to them.  And don’t forget the power of allowing your users to communicate with each other. Integrating other social media is a great way to do this.
  3. Provide a hook.  Provide a reason for the user to download the app.  In the example above, the real estate agency offered coupons to local retailers.  Other things you can offer are prizes and discounts on your products/services.
  4. Make it viral.  Make it easy for users to get their peers to download and use your app.
At Appguppy, our platform is built on helping you to turn one sale into many sales and maximize the return on investment for your brand.