├── views ├── index.handlebar ├── app.png ├── csv.png ├── Callout.png ├── Thumbup.png ├── Ratesample.png ├── Thumbdown.png ├── oauth2flow.png ├── oauth2_scopes.png ├── openIdConnectflow.png ├── openIDConnect_scopes.png ├── quickbooks_logo_horz.png ├── C2QB_green_btn_lg_default.png ├── IntuitSignIn-lg-blue@2x copy.jpg ├── Sign_in_blue_btn_lg_default.png └── common.css ├── .gitignore ├── composer.json ├── config.php ├── apiCall.php ├── refreshToken.php ├── callback.php ├── index.php ├── README.md └── LICENSE /views/index.handlebar: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | composer.lock 2 | composer.phar 3 | vendor/ 4 | config.php 5 | .idea/ 6 | -------------------------------------------------------------------------------- /views/app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/app.png -------------------------------------------------------------------------------- /views/csv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/csv.png -------------------------------------------------------------------------------- /views/Callout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/Callout.png -------------------------------------------------------------------------------- /views/Thumbup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/Thumbup.png -------------------------------------------------------------------------------- /views/Ratesample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/Ratesample.png -------------------------------------------------------------------------------- /views/Thumbdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/Thumbdown.png -------------------------------------------------------------------------------- /views/oauth2flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/oauth2flow.png -------------------------------------------------------------------------------- /views/oauth2_scopes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/oauth2_scopes.png -------------------------------------------------------------------------------- /views/openIdConnectflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/openIdConnectflow.png -------------------------------------------------------------------------------- /views/openIDConnect_scopes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/openIDConnect_scopes.png -------------------------------------------------------------------------------- /views/quickbooks_logo_horz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/quickbooks_logo_horz.png -------------------------------------------------------------------------------- /views/C2QB_green_btn_lg_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/C2QB_green_btn_lg_default.png -------------------------------------------------------------------------------- /views/IntuitSignIn-lg-blue@2x copy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/IntuitSignIn-lg-blue@2x copy.jpg -------------------------------------------------------------------------------- /views/Sign_in_blue_btn_lg_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntuitDeveloper/HelloWorld-PHP/HEAD/views/Sign_in_blue_btn_lg_default.png -------------------------------------------------------------------------------- /views/common.css: -------------------------------------------------------------------------------- 1 | #headerLogo { 2 | display: inline-block; 3 | width: 200px; 4 | height: 60px; 5 | } 6 | 7 | #csvLogo { 8 | /*display: inline-block;*/ 9 | width: 50px; 10 | height: 50px; 11 | } -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "intuitdeveloper/helloworld-php", 3 | "description": "A sample PHP Hello Application to demonstrate OAuth2.0", 4 | "type": "library", 5 | "keywords": ["api", "http", "rest", "quickbooks", "smallbusiness"], 6 | "homepage": "http://developer.intuit.com", 7 | "require": { 8 | "quickbooks/v3-php-sdk": ">=5.3.9" 9 | }, 10 | "author": "anil_kumar", 11 | "license": "MIT" 12 | } 13 | -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | 'https://appcenter.intuit.com/connect/oauth2', 4 | 'tokenEndPointUrl' => 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer', 5 | 'client_id' => 'Enter the clietID from Developer Portal', 6 | 'client_secret' => 'Enter the clientSecret from Developer Portal', 7 | 'oauth_scope' => 'com.intuit.quickbooks.accounting openid profile email phone address', 8 | 'oauth_redirect_uri' => 'http://localhost:3000/callback.php', 9 | ) 10 | ?> 11 | -------------------------------------------------------------------------------- /apiCall.php: -------------------------------------------------------------------------------- 1 | 'oauth2', 15 | 'ClientID' => $config['client_id'], 16 | 'ClientSecret' => $config['client_secret'], 17 | 'RedirectURI' => $config['oauth_redirect_uri'], 18 | 'scope' => $config['oauth_scope'], 19 | 'baseUrl' => "development" 20 | )); 21 | 22 | /* 23 | * Retrieve the accessToken value from session variable 24 | */ 25 | $accessToken = $_SESSION['sessionAccessToken']; 26 | 27 | /* 28 | * Update the OAuth2Token of the dataService object 29 | */ 30 | $dataService->updateOAuth2Token($accessToken); 31 | $companyInfo = $dataService->getCompanyInfo(); 32 | $address = "QBO API call Successful!! Response Company name: " . $companyInfo->CompanyName . " Company Address: " . $companyInfo->CompanyAddr->Line1 . " " . $companyInfo->CompanyAddr->City . " " . $companyInfo->CompanyAddr->PostalCode; 33 | print_r($address); 34 | return $companyInfo; 35 | } 36 | 37 | $result = makeAPICall(); 38 | 39 | ?> 40 | -------------------------------------------------------------------------------- /refreshToken.php: -------------------------------------------------------------------------------- 1 | 'oauth2', 19 | 'ClientID' => $config['client_id'], 20 | 'ClientSecret' => $config['client_secret'], 21 | 'RedirectURI' => $config['oauth_redirect_uri'], 22 | 'baseUrl' => "development", 23 | 'refreshTokenKey' => $accessToken->getRefreshToken(), 24 | 'QBORealmID' => "The Company ID which the app wants to access", 25 | )); 26 | 27 | /* 28 | * Update the OAuth2Token of the dataService object 29 | */ 30 | $OAuth2LoginHelper = $dataService->getOAuth2LoginHelper(); 31 | $refreshedAccessTokenObj = $OAuth2LoginHelper->refreshToken(); 32 | $dataService->updateOAuth2Token($refreshedAccessTokenObj); 33 | 34 | $_SESSION['sessionAccessToken'] = $refreshedAccessTokenObj; 35 | 36 | print_r($refreshedAccessTokenObj); 37 | return $refreshedAccessTokenObj; 38 | } 39 | 40 | $result = refreshToken(); 41 | 42 | ?> -------------------------------------------------------------------------------- /callback.php: -------------------------------------------------------------------------------- 1 | 'oauth2', 15 | 'ClientID' => $config['client_id'], 16 | 'ClientSecret' => $config['client_secret'], 17 | 'RedirectURI' => $config['oauth_redirect_uri'], 18 | 'scope' => $config['oauth_scope'], 19 | 'baseUrl' => "development" 20 | )); 21 | 22 | $OAuth2LoginHelper = $dataService->getOAuth2LoginHelper(); 23 | $parseUrl = parseAuthRedirectUrl(htmlspecialchars_decode($_SERVER['QUERY_STRING'])); 24 | 25 | /* 26 | * Update the OAuth2Token 27 | */ 28 | $accessToken = $OAuth2LoginHelper->exchangeAuthorizationCodeForToken($parseUrl['code'], $parseUrl['realmId']); 29 | $dataService->updateOAuth2Token($accessToken); 30 | 31 | /* 32 | * Setting the accessToken for session variable 33 | */ 34 | $_SESSION['sessionAccessToken'] = $accessToken; 35 | } 36 | 37 | function parseAuthRedirectUrl($url) 38 | { 39 | parse_str($url,$qsArray); 40 | return array( 41 | 'code' => $qsArray['code'], 42 | 'realmId' => $qsArray['realmId'] 43 | ); 44 | } 45 | 46 | $result = processCode(); 47 | 48 | ?> 49 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 'oauth2', 12 | 'ClientID' => $config['client_id'], 13 | 'ClientSecret' => $config['client_secret'], 14 | 'RedirectURI' => $config['oauth_redirect_uri'], 15 | 'scope' => $config['oauth_scope'], 16 | 'baseUrl' => "development" 17 | )); 18 | 19 | $OAuth2LoginHelper = $dataService->getOAuth2LoginHelper(); 20 | $authUrl = $OAuth2LoginHelper->getAuthorizationCodeURL(); 21 | 22 | 23 | // Store the url in PHP Session Object; 24 | $_SESSION['authUrl'] = $authUrl; 25 | 26 | //set the access token using the auth object 27 | if (isset($_SESSION['sessionAccessToken'])) { 28 | 29 | $accessToken = $_SESSION['sessionAccessToken']; 30 | $accessTokenJson = array('token_type' => 'bearer', 31 | 'access_token' => $accessToken->getAccessToken(), 32 | 'refresh_token' => $accessToken->getRefreshToken(), 33 | 'x_refresh_token_expires_in' => $accessToken->getRefreshTokenExpiresAt(), 34 | 'expires_in' => $accessToken->getAccessTokenExpiresAt() 35 | ); 36 | $dataService->updateOAuth2Token($accessToken); 37 | $oauthLoginHelper = $dataService -> getOAuth2LoginHelper(); 38 | $CompanyInfo = $dataService->getCompanyInfo(); 39 | } 40 | 41 | ?> 42 | 43 | 44 | 45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 113 | 114 | 115 | 116 |
121 |
122 |
123 | If there is no access token or the access token is invalid, click the Connect to QuickBooks button below.
137 |138 |