将 ASP.NET 应用程序连接到 QuickBooks Online Edition

发布于 2024-07-26 11:58:05 字数 239 浏览 13 评论 0 原文

我正在尝试创建一个连接到 QuickBooks Online Edition 的 ASP.NET 页面,读取几个值并显示结果。 到目前为止,我已经下载了 QuickBooks SDK,但我无法找到有关如何创建 asp.net 页面以连接到 QuickBooks Online 的简单分步示例。 QuickBooks SDK 文档和 SDK 本身非常令人困惑和不知所措。 任何人都知道关于从哪里开始的简单分步教程......或者可能是关于要做的第一件事的提示。

I am trying to create an ASP.NET page that connects to QuickBooks Online Edition, read a couple of values, and display the results. So far I have downloaded the QuickBooks SDK but I have been unable to find a simple step-by-step example on how to create an asp.net page to connect to QuickBooks Online. The QuickBooks SDK documentation and the SDK itself is very confusing and overwhelming. Anyone know of a simple step by step tutorial on where to get started... or maybe a hint on the very first thing to do.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

错爱 2024-08-02 11:58:05

Yishai 的回答部分正确,但不完全正确。

如果您确保设置,您可以让您的 ASP .NET 应用程序登录并发出请求而无需将用户发送到 QuickBooks Online 登录页面当您将应用程序连接到 QuickBooks Online Edition 时,请正确设置安全首选项。

在应用程序注册过程/连接过程中,它会询问您是否要打开或关闭登录安全性,提示如下。 如果您希望能够访问 QuickBooks Online Edition 数据而不每次都强制用户登录,则必须告诉它您想要关闭登录安全性。 提示类似于:

“您要打开登录安全性吗?”

您必须选择:
“不。任何可以登录[应用程序名称]的人都可以使用该连接”。

除此之外,Yishai 对整个过程的看法是正确的。 重申一下,简而言之:

  • 注册 QBOE 帐户
  • 使用 Intuit 的 AppReg 服务注册您的集成应用程序
  • 访问特定链接,将您的 AppReg 应用程序绑定到您的 QBOE 帐户(确保在系统要求时关闭登录安全性!
  • )向 Intuit 服务器发出 HTTPS POST 请求以使用连接票证进行登录 Intuit 将向您提供“
  • 发出 HTTPS POST 请求”以向 Intuit 服务器发送 qbXML 请求,您可以使用该请求在 QuickBooks Online Edition 中添加、修改、删除和查询记录。

我的 QuickBooks 开发和集成 wiki 上有一些附加文档和一些示例请求,特别是 QuickBooks Online Edition 集成 页面。

我已经构建了一个解决方案,可以执行您在 PHP 中要求的操作,该解决方案可以在 QuickBooks Online Edition 中添加、修改和查询数据,而无需用户每次都登录,并且它的工作方式非常出色。 它在 PHP 购物车 (VirtueMart) 和 QuickBooks Online Edition 之间推送和拉取订单数据。 PHP 代码可在此处获取:
QuickBooks PHP 框架

作为旁注,除非您如果您非常熟悉生成 SSL 证书并通过 HTTPS POST 发送证书,那么通过使用 DESKTOP 通信模型(而不是 HOSTED 模型)可以为自己省去很多麻烦。 只需确保您的连接票证安全加密即可。

此外,Yishai 的建议是:“一种是以编程方式打开他们的登录页面并提交凭据,就像您是用户一样。我确信它不“受支持”,但它可能会起作用。” 特别违反 Intuit 和 SDK 规定的安全/开发人员指南。 如果他们发现您这样做,他们将禁止您的应用程序连接到 QuickBooks。

Yishai's answer is partially correct, but not entirely.

You can have your ASP .NET application log in and issue requests without having to send the user over to the QuickBooks Online log in page if you make sure to set the security preferences correctly when you connect up your application to QuickBooks Online Edition.

During the application registration process/connection process, it will ask you if you want to turn on or off login security with a prompt as below. You must tell it you want to turn off login security if you want to be able to access QuickBooks Online Edition data without forcing the user to log in every time. The prompt is something like:

"Do you want to turn on login security?"

You must select:
"No. Anyone who can log into [Application Name] can use the connection".

Outside of that, Yishai is correct about the process. To re-iterate, in a nutshell:

  • Register for a QBOE account
  • Register your integrated application with Intuit's AppReg service
  • Visit a specific link to tie your AppReg application to your QBOE account (make sure you turn off login security when it asks you!)
  • Make HTTPS POST requests to Intuit's servers to sign on using the connection ticket Intuit will provide you with
  • Make HTTPS POST requests to send qbXML requests to Intuit's servers, which you can use to add, modify, delete, and query records within QuickBooks Online Edition.

There is some additional documentation and some example requests on my QuickBooks development and integration wiki, specifically the QuickBooks Online Edition integration page.

I have built a solution that does what you're asking in PHP which adds, modifies, and queries data within QuickBooks Online Edition without requiring the user to log in everytime, and it works like a champ. It pushes and pulls order data between a PHP shopping cart (VirtueMart) and QuickBooks Online Edition. The PHP code is available here:
QuickBooks PHP Framework

As a side note, unless you're very familiar with generating SSL certificates and sending them via HTTPS POSTs, you'll save yourself a whole lot of trouble by using the DESKTOP model of communication, and not the HOSTED model. Just make sure to keep your connection ticket securely encrypted.

Also, Yishai's suggestion to: "One is to programatically hit up their login page and submit the credentials as if you were a user. I'm sure its not "supported" but it would likely work." goes specifically against the security/developer guidelines Intuit and the SDK set forth. If they catch you doing that, they'll ban your application from connecting to QuickBooks.

薄情伤 2024-08-02 11:58:05

以下是我为实现此目的所采取的所有步骤。 特别感谢 Keith Palmer 的评论、回答和 他的网站确实帮助我完成了这项工作。

  1. http://appreg.quickbooks.com 上注册您的应用程序。 这将为您提供应用程序 ID 和应用程序名称。 我使用了这些设置:

    • 目标应用:QBOE
    • 环境:生产
    • 应用程序类型:桌面

      • (使用桌面使事情变得更容易,不需要证书)
    • 验证密钥将发送到您的电子邮件地址,您需要在此向导的第 2 页上输入该地址。

  2. 设置您的 QBOE 连接。 在步骤 1 中完成应用程序注册后,您将获得一个应用程序 ID。 使用下面网址中的此 ID 来设置您的 QBOE 连接:
    • https://login.quickbooks.com /j/qbn/sdkapp/confirm?serviceid=2004&appid=APP_ID
    • 注意:请务必将上述网址中的 APP_ID 替换为您注册应用程序时创建的应用程序 ID。
    • 向导将引导您完成以下步骤:
      1. 指定连接的名称。
      2. 授予访问权限 - 我授予了所有会计权限,因为这是最简单的。
      3. 指定登录安全性 - 我关闭了登录安全性。 这很重要,因为它使向 QBOE 提交 xml 变得更加容易,因为您不需要为每个用户获取会话票证。
      4. 然后您将获得一个连接密钥。
  3. 此时,您现在已掌握3 条重要信息,以便访问您的 QuickBooks Online Edition (QBOE) 帐户。
    • 应用程序名称
    • 应用程序 ID
    • 连接密钥
  4. 将 XML 发布到 QBOE,其中包含 3 条访问信息和实际请求到您的 QBOE 数据库中。 以下是将发布到 QBOE 网关的示例 C# 代码。 这将返回 QuickBooks 数据库中的所有客户。 请务必使用您的应用程序名称、应用程序 ID 和连接密钥更新下面的 xml。

    string requestUrl = null; 
      requestUrl = "https://apps.quickbooks.com/j/AppGateway"; 
    
      HttpWebRequest WebRequestObject = null; 
      StreamReader sr = null; 
      HttpWebResponse WebResponseObject = null; 
      StreamWriter swr = null; 
    
      尝试 
      { 
          WebRequestObject = (HttpWebRequest)WebRequest.Create(requestUrl); 
          WebRequestObject.Method = "POST"; 
          WebRequestObject.ContentType = "application/x-qbxml"; 
          WebRequestObject.AllowAutoRedirect = false; 
    
          字符串 post = @" 
           
           
             
              <登录桌面Rq> 
                %%CLIENT_DATE_TIME%% 
                APPLICATION_LOGIN 
                CONNECTION_TICKET 
                <语言>英语 
                APP_ID 
                <应用程序版本>1 
               
             
             
               
             
          "; 
    
    
    
          post = post.Replace("%%CLIENT_DATE_TIME%%", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss")); 
          XmlDocument xmlDoc = new XmlDocument(); 
          xmlDoc.LoadXml(post); 
          帖子 = xmlDoc.InnerXml; 
          WebRequestObject.ContentLength = post.Length; 
          swr = new StreamWriter(WebRequestObject.GetRequestStream()); 
          swr.Write(post); 
          swr.Close(); 
          WebResponseObject = (HttpWebResponse)WebRequestObject.GetResponse(); 
          sr = new StreamReader(WebResponseObject.GetResponseStream()); 
          字符串结果 = sr.ReadToEnd(); 
          } 
      最后 
          { 
              尝试 
              { 
                  关闭(); 
              } 
              抓住 
              { 
              } 
    
              尝试 
              { 
                  WebResponseObject.Close(); 
                  WebRequestObject.Abort(); 
              } 
              抓住 
              { 
              } 
          } 
      
  5. 需要注意的几点:

    • 正如 Keith Palmer 所指出的,qbxml 版本需要为 6.0(尽管 IDN 统一屏幕参考显示为 7.0)
    • 我需要包含 onError="continueOnError" 属性。
    • 需要设置 WebRequestObject.ContentLength 属性。
    • 内容类型必须为“application/x-qbxml”
    • 最后我收到了很多“远程服务器返回错误:(400) 错误请求”。 异常根本没有帮助,但最终我能够追踪到 xml 的错误。 因此,如果您遇到此异常,请将您的 xml 视为问题根源。

Here are all the steps I took to get this working. Special thanks to Keith Palmer for his comments, answers, and his website which really helped me get this working.

  1. Register your application at http://appreg.quickbooks.com. This will give you your App ID and Application Name. I used these settings:

    • Target Application: QBOE
    • Environment: Production
    • Application Type: Desktop

      • (using Desktop made things much easier as far as not needing certificates)
    • A verification key is sent to your email address which you need to enter on page 2 of this wizard.

  2. Set up your QBOE Connection. Once you finish registering your application in Step 1, you will then have an Application ID. Use this ID in the url below to set up your QBOE Connection:
    • https://login.quickbooks.com/j/qbn/sdkapp/confirm?serviceid=2004&appid=APP_ID
    • NOTE: Make sure to replace APP_ID in the above url with the Application ID that was created when you registered your application.
    • The wizard will take you through the following steps:
      1. Specifying a name for your connection.
      2. Granting Access Rights - I gave All Accounting rights since this was easiest.
      3. Specify Login Security - I turned Login Security Off. This is important since it makes submitting the xml to the QBOE much easier since you do not need to get a session ticket for each user.
      4. You will then be given a Connection Key.
  3. At this point you now have the 3 important pieces of information in order to gain access to your QuickBooks Online Edition (QBOE) account.
    • Application Name
    • Application ID
    • Connection Key
  4. Post the XML to QBOE with the 3 pieces of access information and the actual request into your QBOE database. Here is sample c# code that will post to the QBOE gateway. This will return all customers in your QuickBooks database. Make sure to update the xml below with your Application Name, Application ID, and Connection Key.

    string requestUrl = null;
    requestUrl = "https://apps.quickbooks.com/j/AppGateway";
    
    HttpWebRequest WebRequestObject = null;
    StreamReader sr = null;
    HttpWebResponse WebResponseObject = null;
    StreamWriter swr = null;
    
    try
    {
        WebRequestObject = (HttpWebRequest)WebRequest.Create(requestUrl);
        WebRequestObject.Method = "POST";
        WebRequestObject.ContentType = "application/x-qbxml";
        WebRequestObject.AllowAutoRedirect = false;
    
        string post = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
        <?qbxml version=""6.0""?>
        <QBXML>
          <SignonMsgsRq>
            <SignonDesktopRq>
              <ClientDateTime>%%CLIENT_DATE_TIME%%</ClientDateTime>
              <ApplicationLogin>APPLICATION_LOGIN</ApplicationLogin>
              <ConnectionTicket>CONNECTION_TICKET</ConnectionTicket>
              <Language>English</Language>
              <AppID>APP_ID</AppID>
              <AppVer>1</AppVer>
            </SignonDesktopRq>
          </SignonMsgsRq>
          <QBXMLMsgsRq onError=""continueOnError"">
            <CustomerQueryRq requestID=""2"" />
          </QBXMLMsgsRq>
        </QBXML>";
    
    
    
        post = post.Replace("%%CLIENT_DATE_TIME%%", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"));
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(post);
        post = xmlDoc.InnerXml;
        WebRequestObject.ContentLength = post.Length;
        swr = new StreamWriter(WebRequestObject.GetRequestStream());
        swr.Write(post);
        swr.Close();
        WebResponseObject = (HttpWebResponse)WebRequestObject.GetResponse();
        sr = new StreamReader(WebResponseObject.GetResponseStream());
        string Results = sr.ReadToEnd();
        }
    finally
        {
            try
            {
                sr.Close();
            }
            catch
            {
            }
    
            try
            {
                WebResponseObject.Close();
                WebRequestObject.Abort();
            }
            catch
            {
            }
        }
    
  5. Couple things to note:

    • As pointed out by Keith Palmer the qbxml version needs to be 6.0 (even though the IDN Unified On-Screen Reference shows 7.0)
    • I needed to include the onError="continueOnError" attribute.
    • Setting the WebRequestObject.ContentLength property is required.
    • Content Type needs to be "application/x-qbxml"
    • And finally I received many "The remote server returned an error: (400) Bad Request." exceptions which were not helpful at all but in the end I was able to trace them to something wrong with the xml. So if you get this exception look to your xml as the source of the problem.
熟人话多 2024-08-02 11:58:05

QBSDK 文档的第 7 章概述了您必须执行的操作(至少在我拥有的 7.0 版本的 SDK 中)。 您必须开设一个测试帐户并获得连接到他们的服务器的权限。

设置帐户后,基本身份验证过程包括将用户重定向到 QuickBooks Online 站点进行登录,用户完成此操作后,QuickBooks 会通过带有票证的 HTTPS 帖子回调您的应用程序,这基本上是一个您可以将其用于请求的会话句柄,以便系统知道您已通过身份验证。 当您收到该响应时,您可以解析它并根据返回的内容将您自己的登录请求发送到系统。

然后(如果我正确理解了文档)您基本上是使用 QuickBooks 请求对 xml 文件进行 Https POST,并且获得 XML 响应,您必须对其进行解析才能获取所需的数据。

我希望这能让你开始。

SDK 的其余部分是文档(您需要知道如何形成请求并解析响应),其他所有内容都与如何与桌面产品通信有关。 您从文档的其余部分中唯一需要的是如何进行错误处理,这实际上仅在您将数据发布到 QuickBooks 时才重要。 如果您只是阅读,那并不重要(无论您的请求成功还是失败,您都无需担心是否需要重试或是否会导致重复数据)。

编辑:鉴于您的具体用例,我看到两个选项。 (你并没有疯,只是不是典型的 QuickBooks Online 场景)。

一种是以编程方式打开他们的登录页面并提交凭据,就像您是用户一样。 我确信它不“受支持”,但它可能会起作用。

另一个是缓存结果(无论如何你都应该这样做)并有一个管理屏幕,有人可以在线登录 QuickBooks 并每天早上或晚上或任何有意义的时间更新结果。

在大多数小型企业中,他们会选择第一个选项,但第二个选项会更一致、更稳健,并且如果您遇到问题,实际上会得到 Intuit 的支持。

The outline of what you have to do are outlined in Chapter 7 of the QBSDK documentation (at least in the 7.0 version of the SDK that I have). You have to open a test account and get permission to connect to their servers.

Once you have your account setup, the basic authentication procedure consists of redirecting your user to the QuickBooks Online site to log in, and once the user has done that, QuickBooks calls back your application with an HTTPS post with a ticket, which is basically a session handle that you can use for your requests, so that the system knows you are authenticated. When you get that response, you parse it and send your own login request to the system based on what you got back.

Then (if I understood the documentation correctly) you are basically doing Https POSTS of xml files with the QuickBooks requests, and you get XML responses that you have to parse to get the data you want.

I hope that gets you started.

The rest of the SDK is documentation (which you will need to know how to form your requests and parse your responses) and everything else is concerned with how to communicate with the desktop product. The only thing you are going to need from the rest of the documentation is how to do error handling, which is really only important if you are posting data to QuickBooks. If you are just reading, it doesn't matter (either your request works out or it doesn't, you don't need to worry about if you need to retry or if that would result in duplicate data).

EDIT: Given your specific use case I see two options. (You aren't crazy, just not the typical QuickBooks Online scenario).

One is to programatically hit up their login page and submit the credentials as if you were a user. I'm sure its not "supported" but it would likely work.

The other is to cache the results (which you should probably do anyway) and have an admin screen where someone does log into QuickBooks online and update the results every morning or evening or whatever makes sense.

In most small businesses, they are going to opt for the first option, but the second one is going to work more consistently, robustly and actually be supported by Intuit if you have an issue.

初见你 2024-08-02 11:58:05

这看起来非常接近您所需要的: www.QuickbooksConnector.com

无法下载它吧。

This looks pretty close to what you need: www.QuickbooksConnector.com

Wasn't able to download it yet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文