0

I was trying to connect QuickBooks Online with PHP. I am using Xampp server Windows operating system.

I followed API from consolibyte. I downloaded the Quickbooks-PHP-Master repository and made changes to config.php file.

I have an app on Intuit Development and have 3 keys.

When I run the index.php page, it all works.

But when I click on "connect to quickbooks" button. Error appears:

Error Code: internal_error Message: Error getting application from request token

error_reporting(E_ALL);
ini_set('display_errors', 1);

// Require the library code
require_once dirname(__FILE__) . '/../../../QuickBooks.php';

$token = '76ac0cdabc168b42c2bb997bba4ef0beb2c0';

$oauth_consumer_key = 'qyprdkDO0aY2NHrrk9xx6JZB3xbrIB';
$oauth_consumer_secret = 'eqcBAjc8SnOpVsz49Nf6H5ms58Ns2Up4PJPAe8o5';

 $sandbox = true; 

 $quickbooks_oauth_url = 'http://localhost:81/quickbooks-php-   master/docs/partner_platform/example_app_ipp_v3/oauth.php';

 $quickbooks_success_url = 'http://localhost:81/quickbooks-php-master/docs/partner_platform/example_app_ipp_v3/success.php';


 $quickbooks_menu_url = 'http://localhost:81/quickbooks-php-master/docs/partner_platform/example_app_ipp_v3/menu.php';

 $dsn = 'mysqli://root:@localhost/test';

  $encryption_key = 'bcde1234';

  $the_username = 'DO_NOT_CHANGE_ME';

   $the_tenant = 12345;

   if (!QuickBooks_Utilities::initialized($dsn))

     {

    QuickBooks_Utilities::initialize($dsn);
     }

   $IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere($dsn,            $encryption_key, $oauth_consumer_key, $oauth_consumer_secret,          $quickbooks_oauth_url, $quickbooks_success_url);


   if ($IntuitAnywhere->check($the_username, $the_tenant) and 

    $IntuitAnywhere->test($the_username, $the_tenant))

    {

     $quickbooks_is_connected = true;


     $IPP = new QuickBooks_IPP($dsn);


       $creds = $IntuitAnywhere->load($the_username, $the_tenant);


      $IPP->authMode(
        QuickBooks_IPP::AUTHMODE_OAUTH, 
      $the_username, 
       $creds);

       if ($sandbox)
        {

       $IPP->sandbox(true);
       }

        $realm = $creds['qb_realm'];


       $Context = $IPP->context();

        $CompanyInfoService = new QuickBooks_IPP_Service_CompanyInfo();
      $quickbooks_CompanyInfo = $CompanyInfoService->get($Context, $realm);
       }
       else
        {

        $quickbooks_is_connected = false;
        }

Any solutions please.

Error Message image

Keys image

The response of troubleshooting.php file

  Trying to hit URL: https://oauth.intuit.com/oauth/v1/get_request_token

     Did we disable SSL checks? false
    <br />
       <b>Warning</b>:  curl_setopt(): cannot represent a stream of type          Output as a STDIO FILE* in <b>C:\xampp\htdocs\quickbook2\quickbooks-php-master\docs\partner_platform\example_app_ipp_v3\troubleshooting.php</b> on line <b>30</b><br />


     Trying to hit URL:    https://appcenter.intuit.com/api/v1/Connection/Reconnect

      Did we disable SSL checks? false
    <br />
     <b>Warning</b>:  curl_setopt(): cannot represent a stream of type Output     as a STDIO FILE* in <b>C:\xampp\htdocs\quickbook2\quickbooks-php-master\docs\partner_platform\example_app_ipp_v3\troubleshooting.php</b> on line <b>30</b><br />

       Trying to hit URL: https://oauth.intuit.com/oauth/v1/get_request_token

         Did we disable SSL checks? true
        <br />
         <b>Warning</b>:  curl_setopt(): cannot represent a stream of type  Output as a STDIO FILE* in <b>C:\xampp\htdocs\quickbook2\quickbooks-php-  master\docs\partner_platform\example_app_ipp_v3\troubleshooting.php</b> on line    <b>30</b><br />

      oauth_problem=parameter_absent&oauth_parameters_absent=oauth_signature

       Trying to hit URL: https://appcenter.intuit.com/api/v1/Connection/Reconnect

        Did we disable SSL checks? true
         <br />
           <b>Warning</b>:  curl_setopt(): cannot represent a stream of type Output as a STDIO FILE* in <b>C:\xampp\htdocs\quickbook2\quickbooks-php-master\docs\partner_platform\example_app_ipp_v3\troubleshooting.php</b> on line <b>30</b><br />

          <?xml version="1.0" encoding="utf-8"?>
          <PlatformResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema"           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns="http://platform.intuit.com/api/v1">
           <ErrorMessage>Authentication required</ErrorMessage>
          <ErrorCode>22</ErrorCode>
          <ServerTime>2017-03-23T13:08:09.853153Z</ServerTime>
          </PlatformResponse>


         php version: 5.6.30
         mcrypt extension? true
         mcrypt module rijndael-256? NULL
         curl extension? true
  • Post your code. Post a screenshot of your sandbox credentials on Intuit's site. Check to make sure you have the curl and mcrypt extensions. Check to make sure if you're using sandbox credentials, you have $sandbox set to TRUE. – Keith Palmer Jr. Mar 23 '17 at 02:33
  • Hello Keith. Thanks for your response. What I've done is edited my question with error message and keys images. I've also added my config.php file code. I am using an trial account on quickbooks. So there isn't a real company assigned on my quickbooks account. I just wanted to make trial work first than go ahead with real company. I can give you my Intuit developer credentials if you required. – Muhammad Ikram Mar 23 '17 at 09:10
  • I just checked in a 'troubleshooting.php' script to the repo. Can you git pull that and post the output of that file? – Keith Palmer Jr. Mar 23 '17 at 11:33
  • Hello Keith: I re-edited my original question. I've added the response of troubleshooting.php file. Please look for The response of troubleshooting.php file heading in my original question. – Muhammad Ikram Mar 23 '17 at 13:16

1 Answers1

0

Based on what you've posted above, it looks like your PHP installation doesn't properly validate SSL certificates.

Try this:

Change this line to if (true):

Change this line to if (true):

Try it again. If that fixes it, then you know that your PHP installation is broken -- it doesn't properly validate SSL certificates.

You should then look into fixing your PHP installation:

Community
  • 1
  • 1
Keith Palmer Jr.
  • 27,666
  • 16
  • 68
  • 105
  • Thank you a lot Keith. Above 2 lines of code have fixed the issue. It is connected now. I can run various queries now. What I also was hoping is the data from quickbooks will get saved in MySQL. is there a way of creating tables of data in mysqli like table for customers, suppliers etc... – Muhammad Ikram Mar 23 '17 at 13:55
  • Yes. Google for "how to create a table with php and mysql" – Keith Palmer Jr. Mar 23 '17 at 15:53