Quickbooks api不返回数据

Quickbooks api不返回数据,quickbooks,quickbooks-online,Quickbooks,Quickbooks Online,大家好,我正在按照本教程“”设置api并从quickbooks获取数据。我已经成功地设置了api,但是我现在面临的问题是我无法从QuickBooks中获取数据。它总是返回null,即使那里有很多数据 这是我正在做的代码 config.php <?php // setting up session /* note: This is not a secure way to store oAuth tokens. You should use a secure * data

大家好,我正在按照本教程“”设置api并从quickbooks获取数据。我已经成功地设置了api,但是我现在面临的问题是我无法从QuickBooks中获取数据。它总是返回null,即使那里有很多数据

这是我正在做的代码

config.php

<?php
  // setting up session
  /* note: This is not a secure way to store oAuth tokens. You should use a secure
  *     data sore. We use this for simplicity in this example.
  */
  // session_save_path('./abc/temp');
  session_save_path('./abc/temp');
  session_start();

  echo "<h4>If you see a Session warning above you need to run the command: 'chmod 777 temp' in the terminal on the code page. </h4>";

  define('OAUTH_CONSUMER_KEY', 'some key');
  define('OAUTH_CONSUMER_SECRET', 'some key');


  if(strlen(OAUTH_CONSUMER_KEY) < 5 OR strlen(OAUTH_CONSUMER_SECRET) < 5 ){
    echo "<h3>Set the consumer key and secret in the config.php file before you run this example</h3>";
  }


?>
<?php
  require_once("./config.php");
?>

<html>
<head>

  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>My Connect Page</title>
  <script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script>
  <script>
    // Runnable uses dynamic URLs so we need to detect our current //
    // URL to set the grantUrl value   ########################### //
    /*######*/ var parser = document.createElement('a');/*#########*/
    /*######*/parser.href = document.url;/*########################*/
    // end runnable specific code snipit ##########################//
    intuit.ipp.anywhere.setup({
        menuProxy: '',
        grantUrl: 'http://'+parser.hostname+'/QuickbooksTest/oauth.php?start=t' 
        // outside runnable you can point directly to the oauth.php page
    });
  </script>
</head>

</head>
<body>

<?php
require_once('./v3-php-sdk-2.3.0/config.php');  // Default V3 PHP SDK (v2.0.1) from IPP
require_once(PATH_SDK_ROOT . 'Core/ServiceContext.php');
require_once(PATH_SDK_ROOT . 'DataService/DataService.php');
require_once(PATH_SDK_ROOT . 'PlatformService/PlatformService.php');
require_once(PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php');

error_reporting(E_ERROR | E_PARSE);

// print connect to QuickBooks button to the page
echo "<ipp:connectToIntuit></ipp:connectToIntuit><br />";

// After the oauth process the oauth token and secret 
// are storred in session variables. 
if(!isset($_SESSION['token'])){
  echo "<h3>You are not currently authenticated</h3>";
} else {
  $token = unserialize($_SESSION['token']);
  $requestValidator = new OAuthRequestValidator(
  $token['oauth_token'], $token['oauth_token_secret'], OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
  $realmId = $_SESSION['realmId'];

  // uncomment any of these to see more information 
  //echo "realmId: $realmId <br />";
  //echo "oauth token: ". $token['oauth_token'] . "<br />";
  //echo "oauth secret: ". $token['oauth_token'] . "<br />";
  /*echo "<pre><h2>Session Variables</h2>";
    var_dump($_SESSION);
    echo "</pre>"; */

  $serviceType = $_SESSION['dataSource'];
  $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator);

  $dataService = new DataService($serviceContext);

  // $startPosition = 1;
  // $maxResults = 10;
  // $allCustomers = $dataService->FindAll('Customer', $startPosition, $maxResults);
  $allCustomers = $dataService->Query("SELECT * FROM Customer");
  echo "<pre><h2>Customers List</h2>";
  var_dump($allCustomers);
  echo "</pre>";

}
?>

</body>
</html>


您是否启用了日志记录?日志显示了什么?您是否确实单击了“连接到QuickBooks”按钮并连接到QuickBooks?@KeithPalmerJr。是的,我已连接到quickboks,但我不知道如何启用logging@KeithPalmerJr. 您能指导我如何启用日志记录吗?我将从文档开始:@KeithPalmerJr。我应该把它放在哪里。我应该把它放在配置文件中吗
<?php
  require_once("./config.php");
?>

<html>
<head>

  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>My Connect Page</title>
  <script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script>
  <script>
    // Runnable uses dynamic URLs so we need to detect our current //
    // URL to set the grantUrl value   ########################### //
    /*######*/ var parser = document.createElement('a');/*#########*/
    /*######*/parser.href = document.url;/*########################*/
    // end runnable specific code snipit ##########################//
    intuit.ipp.anywhere.setup({
        menuProxy: '',
        grantUrl: 'http://'+parser.hostname+'/testProject/oauth.php?start=t' 
        // outside runnable you can point directly to the oauth.php page
    });
  </script>
</head>

</head>
<body>

<intuit>
  <ipp>
    <logger>       
      <!-- To enable/disable Request and Response log-->
      <requestLog enableRequestResponseLogging="true" requestResponseLoggingDirectory="C:\IdsLogs" />    
    </logger>
  </ipp>
</intuit>


<?php
require_once('./v3-php-sdk-2.3.0/config.php');  // Default V3 PHP SDK (v2.0.1) from IPP
require_once(PATH_SDK_ROOT . 'Core/ServiceContext.php');
require_once(PATH_SDK_ROOT . 'DataService/DataService.php');
require_once(PATH_SDK_ROOT . 'PlatformService/PlatformService.php');
require_once(PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php');
require_once(PATH_SDK_ROOT . 'QueryFilter/QueryMessage.php');

error_reporting(E_ERROR | E_PARSE);

// print connect to QuickBooks button to the page
echo "<ipp:connectToIntuit></ipp:connectToIntuit><br />";

// After the oauth process the oauth token and secret 
// are storred in session variables. 
if(!isset($_SESSION['token'])){
  echo "<h3>You are not currently authenticated</h3>";
} else {
  $token = unserialize($_SESSION['token']);
  $requestValidator = new OAuthRequestValidator(
  $token['oauth_token'], $token['oauth_token_secret'], OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
  $realmId = $_SESSION['realmId'];


  error_log($realmId);  
  // uncomment any of these to see more information 
  //echo "realmId: $realmId <br />";
  //echo "oauth token: ". $token['oauth_token'] . "<br />";
  //echo "oauth secret: ". $token['oauth_token'] . "<br />";
  /*echo "<pre><h2>Session Variables</h2>";
    var_dump($_SESSION);
    echo "</pre>"; */


  // error_log("Value in dataSource session is: " . $_SESSION['dataSource']);
  // $serviceType = $_SESSION['dataSource']; //5:15 PM
  $serviceType = IntuitServicesType::QBO; //5:16 PM
  $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator);

  $dataService = new DataService($serviceContext);

  // $startPosition = 1;
  // $maxResults = 10;
  // $allCustomers = $dataService->FindAll('Customer', $startPosition, $maxResults);
  // $allCustomers = $dataService->Query("SELECT * FROM Customer");
  $allCustomers = $dataService->FindAll('Customer');

  // $oneQuery = new QueryMessage();
  // $oneQuery->sql = "SELECT";
  // $oneQuery->entity = "Customer";
  // $oneQuery->orderByClause = "FamilyName";

  // Run a query
  // $queryString = $oneQuery->getString();
  // $allCustomers = $dataService->Query($queryString);

  // $ch = curl_init("http://www.example.com/");
  // $fp = fopen("example_homepage.txt", "w");

  // curl_setopt($ch, CURLOPT_FILE, $fp);
  // curl_setopt($ch, CURLOPT_HEADER, 0);

  // curl_exec($ch);
  // curl_close($ch);
  // fclose($fp);



  echo "<pre><h2>Customers List</h2>";
  var_dump($allCustomers);
  echo "</pre>";

}
?>

</body>
</html>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <intuit>
    <ipp>
      <!--Json serialization not supported in PHP SDK v2.0.0 -->
      <message>
        <request serializationFormat="Xml" compressionFormat="None"/>
        <response serializationFormat="Xml" compressionFormat="None"/>
      </message>
      <service>
        <baseUrl qbd="https://quickbooks.api.intuit.com/" qbo="https://quickbooks.api.intuit.com/" ipp="https://appcenter.intuit.com/api/" />
      </service>
      <logger>
        <!-- To enable/disable Request and Response log-->
        <requestLog enableRequestResponseLogging="true" requestResponseLoggingDirectory="./IdsLogs" />
      </logger>
    </ipp>
  </intuit>
</configuration>