Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Visual FoxPro Web API Examples

Primary Categories

ABN AMRO
AWS Translate
Activix CRM
Adyen
Amazon DynamoDB
Amazon MWS
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bitfinex v2 REST
Bluzone
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
ETrade
Egypt ITIDA
Etsy
Facebook
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
IntakeQ
Jira
Lightspeed
MYOB
Magento

MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Okta OAuth/OIDC
OneLogin OIDC
OneNote
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
SimpleTexting
Square
Stripe
SugarCRM
Trello
Twilio
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yousign
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Visual FoxPro) SII POST boleta.electronica.token

Obtener un token de at autenticación para el envío y consultas automatizadas de boletas electrónicas.

For more information, see https://www4c.sii.cl/bolcoreinternetui/api/

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

LOCAL loXmlToSign
LOCAL loGen
LOCAL loCert
LOCAL lnSuccess
LOCAL loSbXml
LOCAL loHttp
LOCAL lcUrl
LOCAL loResp
LOCAL loXml
LOCAL lnESTADO
LOCAL lcGLOSA
LOCAL lcTOKEN

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

* Create the XML to be signed...
* The following XML is created:
* 
*   <?xml version="1.0" encoding="UTF-8"?>
*   <getToken><item><Semilla>030530912644</Semilla></item></getToken>
* 
loXmlToSign = CreateObject('Chilkat_9_5_0.Xml')
loXmlToSign.Tag = "getToken"
loXmlToSign.UpdateChildContent("item|Semilla","030530912644")

* Sign the XML.
* 
* We wish to create the following signed XML:

*   <?xml version="1.0" encoding="UTF-8"?>
*   <getToken>
*   	<item>
*   		<Semilla>030530912644</Semilla>
*   	</item>
*   	<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
*   		<SignedInfo>
*   			<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315">
*   			</CanonicalizationMethod>
*   			<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1">
*   			</SignatureMethod>
*   			<Reference URI="">
*   				<Transforms>
*   					<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature">
*   					</Transform>
*   				</Transforms>
*   				<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1">
*   				</DigestMethod>
*   				<DigestValue>l2s9BqLppHaWo+w1Al1J5SsYScs=</DigestValue>
*   			</Reference>
*   		</SignedInfo>
*   		<SignatureValue>jlbzatIIBLW8AjH++5uVTTrGIMVwGButuoAR88y/hvSc1+6/eW1K864fK3cKi76oArqk7lAM4pP okoXme0JT/hRXXGo6ecuKzO18z2WfPWwgnN0f3ac03TDu7PwfqiDG9mhQpYfIkNp6GNJIiqlg9PG2w1fOJ1QoypsrQmKq6 YU=</SignatureValue>
*   		<KeyInfo>
*   			<KeyValue>
*   				<RSAKeyValue>
*   					<Modulus>2Pb4kEB19m7NmOUYew9f36325yrTLTPMU7qzYG2A0/BsubxDdgQw2Op0x6zXvOVX sYI9KkPXtD5orKJMjwxYRv9wUWdyiE776Rv4ljfJO7EQhIK1fDQDnPt0HefBS06Xzg2QLBvLR+pe1vc6C02Dr99v+lnLA8 mnZiJlRHndhNU=</Modulus>
*   					<Exponent>AQAB</Exponent>
*   				</RSAKeyValue>
*   			</KeyValue>
*   			<X509Data>
*   				<X509Certificate>MIIF1DCCBLygAwIBAgIDAQNtMA0GCSqGSIb3DQEBBQUAMIHGMQswCQYDVQQG
*   EwJDTDEYMBYGA1UEChMPQWNlcHRhLmNvbSBTLkEuMTgwNgYDVQQLEy9BdXRv
*   cmlkYWQgY2VydGlmaWNhZG9yYSBDbGFzZSAzIHBlcnNvbmEgbmF0dXJhbDFD
*   MEEGA1UEAxM6QWNlcHRhLmNvbSBBdXRvcmlkYWQgY2VydGlmaWNhZG9yYSBD
*   bGFzZSAzIHBlcnNvbmEgbmF0dXJhbDEeMBwGCSqGSIb3DQEJARYPaW5mb0Bh
*   Y2VwdGEuY29tMB4XDTAxMDkyNTIxMDgxMloXDTAyMDkyNTIxMDgxMlowgZ8x
*   CzAJBgNVBAYTAkNMMRgwFgYDVQQKEw9BY2VwdGEuY29tIFMuQS4xLDAqBgNV
*   BAsTI0NlcnRpZmljYWRvIENsYXNlIDMgUGVyc29uYSBOYXR1cmFsMRwwGgYJ
*   KoZIhvcNAQkBFg1uY2hlbGVAc2lpLmNsMSowKAYDVQQDEyFOSUNPTEFTIFpB
*   UFJJQU4gQ0hFTEVCSUZTS0kgQkFFWkEwgZ8wDQYJKoZIhvcNAQEBBQADgY0A
*   MIGJAoGBANj2+JBAdfZuzZjlGHsPX9+t9ucq0y0zzFO6s2BtgNPwbLm8Q3YE
*   MNjqdMes17zlV7GCPSpD17Q+aKyiTI8MWEb/cFFncohO++kb+JY3yTuxEISC
*   tXw0A5z7dB3nwUtOl84NkCwby0fqXtb3OgtNg6/fb/pZywPJp2YiZUR53YTV
*   AgMBAAGjggJyMIICbjAdBggrBgEEAbVrDwQRFg9BY2VwdGEuY29tIFMuQS4w
*   JQYDVR0RBB4wHKAaBggrBgEEAcEBAaAOFgwxMC40MTEuODcxLTIwDwYIKwYB
*   Jh0z1DR3Pl3xOiaFIjSXsQO2PSzcA3wZXYF+KDrMul8e5lAF2NNiLmMVtXEx
*   ZykMaTGGWS0ZETDhJmBwEZGpP4+lt/JhgwF1Sb6wdrXp7MFCJUc1Tj+/5JqH
*   1kP0E63/hVElrcP0g8Zn8Z+vr/PMGW1kKgE0IyS4iJ8eIhNSK5phFyKJUn0l
*   BmIZX7u89d5u7X8=
*   </X509Certificate>
*   			</X509Data>
*   		</KeyInfo>
*   	</Signature>
*   </getToken>

loGen = CreateObject('Chilkat_9_5_0.XmlDSigGen')

loGen.SigLocation = "getToken"
loGen.SigLocationMod = 0
loGen.SigNamespacePrefix = ""
loGen.SigNamespaceUri = "http://www.w3.org/2000/09/xmldsig#"
loGen.SignedInfoCanonAlg = "C14N"
loGen.SignedInfoDigestMethod = "sha1"

* -------- Reference 1 --------
loGen.AddSameDocRef("","sha1","","","")

* Provide a certificate + private key. (PFX password is test123)
loCert = CreateObject('Chilkat_9_5_0.Cert')
lnSuccess = loCert.LoadPfxFile("qa_data/pfx/cert_test123.pfx","test123")
IF (lnSuccess <> 1) THEN
    ? loCert.LastErrorText
    RELEASE loXmlToSign
    RELEASE loGen
    RELEASE loCert
    CANCEL
ENDIF

loGen.SetX509Cert(loCert,1)

loGen.KeyInfoType = "X509Data+KeyValue"
loGen.X509Type = "Certificate"

* Load XML to be signed...
loSbXml = CreateObject('Chilkat_9_5_0.StringBuilder')
loXmlToSign.GetXmlSb(loSbXml)

loGen.Behaviors = "IndentedSignature"

* Sign the XML...
lnSuccess = loGen.CreateXmlDSigSb(loSbXml)
IF (lnSuccess <> 1) THEN
    ? loGen.LastErrorText
    RELEASE loXmlToSign
    RELEASE loGen
    RELEASE loCert
    RELEASE loSbXml
    CANCEL
ENDIF

? loSbXml.GetAsString()

* Send the POST with signed XML in the request body
loHttp = CreateObject('Chilkat_9_5_0.Http')

loHttp.SetRequestHeader("accept","application/xml")

* Use one of the following domains, depending on the environment:
* apicert.sii.cl  - Certification Environment
* api.sii.cl      - Production Environment
lcUrl = "https://apicert.sii.cl/recursos/v1/boleta.electronica.token"
loResp = loHttp.PostXml(lcUrl,loSbXml.GetAsString(),"utf-8")
IF (loHttp.LastMethodSuccess <> 1) THEN
    ? loHttp.LastErrorText
    RELEASE loXmlToSign
    RELEASE loGen
    RELEASE loCert
    RELEASE loSbXml
    RELEASE loHttp
    CANCEL
ENDIF

* Examine the response status code:
? "response status code = " + STR(loResp.StatusCode)

* Examine the response body:
? "response body: " + loResp.BodyStr

* We expect a response like this:
*   <?xml version="1.0" encoding="UTF-8"?>
*   <SII:RESPUESTA xmlns:SII="http://www.sii.cl/XMLSchema">
*   	<SII:RESP_HDR>
*   		<ESTADO>00</ESTADO>
*   		<GLOSA>Token Creado</GLOSA>
*   	</SII:RESP_HDR>
*   	<SII:RESP_BODY>
*   		<TOKEN>XAuSbYXiNh9Ik</TOKEN>
*   	</SII:RESP_BODY>
*   </SII:RESPUESTA>

* Parse the XML response.
loXml = CreateObject('Chilkat_9_5_0.Xml')
loXml.LoadXml(loResp.BodyStr)
lnESTADO = loXml.GetChildIntValue("SII:RESP_HDR|ESTADO")
lcGLOSA = loXml.GetChildContent("SII:RESP_HDR|GLOSA")
lcTOKEN = loXml.GetChildContent("SII:RESP_BODY|TOKEN")

RELEASE loResp

RELEASE loXmlToSign
RELEASE loGen
RELEASE loCert
RELEASE loSbXml
RELEASE loHttp
RELEASE loXml


 

© 2000-2021 Chilkat Software, Inc. All Rights Reserved.