Ранее я задавал этот вопрос, но проблема все еще продолжается. Более подробную информацию можно найти по ссылке ниже. Как подключиться к PHP QucckBooks с помощью API Consolibyte .
У меня есть приложение PHP, и я хотел бы подключить QB онлайн с моим приложением с помощью API Consolibyte.
Я создал хранилище и получил токены.
Но когда я нажимаю «Подключиться к быстрой книге»
Я получаю сообщение об ошибке
«Невозможно создать URL авторизации. Нет, что-то плохое случилось "
Код:
// Require the library code
require_once dirname(__FILE__) . '/../../../QuickBooks.php';
// Your OAuth consumer key and secret (Intuit will give you both of these when you register an Intuit app)
//
// IMPORTANT:
// To pass your tech review with Intuit, you'll have to AES encrypt these and
// store them somewhere safe.
//
// The OAuth request/access tokens will be encrypted and stored for you by the
// PHP DevKit IntuitAnywhere classes automatically.
$oauth_client_id = 'xxxxxxxxxx';
$oauth_client_secret = 'xxxxxxxxxx';
// If you're using DEVELOPMENT TOKENS, you MUST USE SANDBOX MODE!!! If you're in PRODUCTION, then DO NOT use sandbox.
//$sandbox = true; // When you're using development tokens
$sandbox = false; // When you're using production tokens
// This is the URL of your OAuth auth handler page
$quickbooks_oauth_url = 'http://xxxxxxxqb/docs/partner_platform/example_app_ipp_v3/oauth.php';
// This is the URL to forward the user to after they have connected to IPP/IDS via OAuth
$quickbooks_success_url = 'http://xxxxxxxxqb/docs/partner_platform/example_app_ipp_v3/success.phpf';
// This is the menu URL script
$quickbooks_menu_url = 'http://xxxxxxxxx/qb/docs/partner_platform/example_app_ipp_v3/menu.php';
// This is a database connection string that will be used to store the OAuth credentials
// $dsn = 'pgsql://username:password@hostname/database';
// $dsn = 'mysql://username:password@hostname/database';
$dsn = 'mysqli://xxxxxxx@localhost/xxxxxx';
// You should set this to an encryption key specific to your app
$encryption_key = 'bcde1234';
// Scope required
$scope = 'com.intuit.quickbooks.accounting ';
// The tenant that user is accessing within your own app
$the_tenant = 12345;
РЕДАКТИРОВАТЬ
/**
* Intuit Partner Platform configuration variables
*
* See the scripts that use these variables for more details.
*
* @package QuickBooks
* @subpackage Documentation
*/
// Turn on some error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Require the library code
require_once dirname(__FILE__) . '/../../../QuickBooks.php';
// Your OAuth consumer key and secret (Intuit will give you both of these when you register an Intuit app)
//
// IMPORTANT:
// To pass your tech review with Intuit, you'll have to AES encrypt these and
// store them somewhere safe.
//
// The OAuth request/access tokens will be encrypted and stored for you by the
// PHP DevKit IntuitAnywhere classes automatically.
$oauth_client_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$oauth_client_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxx';
// If you're using DEVELOPMENT TOKENS, you MUST USE SANDBOX MODE!!! If you're in PRODUCTION, then DO NOT use sandbox.
//$sandbox = true; // When you're using development tokens
$sandbox = false; // When you're using production tokens
x
// This is the URL of your OAuth auth handler page
$quickbooks_oauth_url = 'https://xxxxxxxxxxx/qb/docs/partner_platform/example_app_ipp_v3/oauth.php';
// This is the URL to forward the user to after they have connected to IPP/IDS via OAuth
$quickbooks_success_url = 'https://xxxxxxxxxxxxx/qb/docs/partner_platform/example_app_ipp_v3/success.php';
// This is the menu URL script
$quickbooks_menu_url = 'https://xxxxxxxxxxxx/qb/docs/partner_platform/example_app_ipp_v3/menu.php';
https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl
// This is a database connection string that will be used to store the OAuth credentials
// $dsn = 'pgsql://username:password@hostname/database';
// $dsn = 'mysql://username:password@hostname/database';
$dsn = 'mysqli://xxxxx:xxxxxx@localhost/xxxxx';
// You should set this to an encryption key specific to your app
$encryption_key = 'bcde1234';
// Scope required
$scope = 'com.intuit.quickbooks.accounting ';
// The tenant that user is accessing within your own app
$the_tenant = 12345;
// Initialize the database tables for storing OAuth information
if (!QuickBooks_Utilities::initialized($dsn))
{
// Initialize creates the neccessary database schema for queueing up requests and logging
QuickBooks_Utilities::initialize($dsn);
}
// Instantiate our Intuit Anywhere auth handler
//
// The parameters passed to the constructor are:
// $oauth_version QuickBooks_IPP_IntuitAnywhere::OAUTH_V2 or QuickBooks_IPP_IntuitAnywhere::OAUTH_V1
// $dsn
// $oauth_consumer_key Intuit will give this to you when you create a new Intuit Anywhere application at AppCenter.Intuit.com
// $oauth_consumer_secret Intuit will give this to you too
// $this_url This is the full URL (e.g. http://path/to/this/file.php) of THIS SCRIPT
// $that_url After the user authenticates, they will be forwarded to this URL
//
$IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere(
QuickBooks_IPP_IntuitAnywhere::OAUTH_V2,
$sandbox,
$scope,
$dsn,
$encryption_key,
$oauth_client_id,
$oauth_client_secret,
$quickbooks_oauth_url,
$quickbooks_success_url);
// Are they connected to QuickBooks right now?
if ($IntuitAnywhere->check($the_tenant) and
$IntuitAnywhere->test($the_tenant))
{
// Yes, they are
$quickbooks_is_connected = true;
// Set up the IPP instance
$IPP = new QuickBooks_IPP($dsn, $encryption_key);
// Get our OAuth credentials from the database
$creds = $IntuitAnywhere->load($the_tenant);
// Tell the framework to load some data from the OAuth store
$IPP->authMode(
QuickBooks_IPP::AUTHMODE_OAUTHV2,
$creds);
if ($sandbox)
{
// Turn on sandbox mode/URLs
$IPP->sandbox(true);
}
// 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
$Context = $IPP->context();
// Get some company info
$CompanyInfoService = new QuickBooks_IPP_Service_CompanyInfo();
$quickbooks_CompanyInfo = $CompanyInfoService->get($Context, $realm);
}
else
{
// No, they are not
$quickbooks_is_connected = false;
}
Oauth. php
/**
* Example of OAuth authentication for an Intuit Anywhere application
*
*
*
* @package QuickBooks
* @subpackage Documentation
*/
/**
* Require the QuickBooks library
*/
require_once dirname(__FILE__) . '/../../../QuickBooks.php';
// For OAuth2 (all new application, and what you should be migrating to)
require_once dirname(__FILE__) . '/config_oauthv2.php';
// For old/legacy applications
//require_once dirname(__FILE__) . '/config_oauthv1.php';
// You can define your own OAuth state if you want
// (useful for associating the initial OAuth request with the response you get back)
$oauth_state = md5(microtime(true));
// Try to handle the OAuth request
if ($IntuitAnywhere->handle($the_tenant, $oauth_state))
{
; // The user has been connected, and will be redirected to $that_url automatically.
}
else
{
// If this happens, something went wrong with the OAuth handshake
die('Oh no, something bad happened: ' . $IntuitAnywhere->errorNumber() . ': ' . $IntuitAnywhere->errorMessage());
}