Chilkat Examples

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

PureBasic Examples

ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
Facebook
FileAccess
Firebase
GMail REST API
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Sheets
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)

Java KeyStore (JKS)
Jira
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
PayPal
Peoplevox
QuickBooks
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Shopify
Socket/SSL/TLS
Spider
Stream
Stripe
SugarCRM
Tar Archive
Twitter
Upload
VoiceBase
Walmart
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(PureBasic) MemberMouse -- getMember API Call

Demonstrates how to use the getMember API call is used to retrieve information about an existing member's account.

See MemberMouse getMember API call for more information.

Chilkat PureBasic Module Download

Chilkat PureBasic Module

IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttpRequest.pb"

Procedure ChilkatExample()

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

    ;  Build the POST request to get a member's data.
    req.i = CkHttpRequest::ckCreate()
    If req.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ;  If your particular API URL is "https://mydomain.com/wp-content/plugins/membermouse/api/request.php",
    ;  then the Path part of the URL is "/wp-content/plugins/membermouse/api/request.php",
    ;  and the Domain part of the URL is "mydomain.com".
    ;  If "https" is used, then the port is 443 (not 80).

    CkHttpRequest::setCkHttpVerb(req, "POST")
    ;  Use the Path part of your API_URL with "?q=/getMember".
    ;  The command, such as /getMember, /createMember, etc. goes in the Path.
    ;  The remainder of the POST arguments are query params that go in the body of the request.
    ;  (Do not put the apikey and apisecret in the Path because the secret will be exposed.
    ;  You want the confidential information to be in the body of the request.)
    CkHttpRequest::setCkPath(req, "/wp-content/plugins/membermouse/api/request.php?q=/getMember")
    CkHttpRequest::setCkContentType(req, "application/x-www-form-urlencoded")

    ;  Add the query params.
    ;  (Use your particular values in place of "MEMBERMOUSE_...")
    CkHttpRequest::ckAddParam(req,"apikey","MEMBERMOUSE_API_KEY")
    CkHttpRequest::ckAddParam(req,"apisecret","MEMBERMOUSE_API_SECRET")
    CkHttpRequest::ckAddParam(req,"email","some_member@somewhere.com")

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ;  Use the Domain part of your API URL here:
    resp.i = CkHttp::ckSynchronousRequest(http,"mydomain.com",443,1,req)
    If CkHttp::ckLastMethodSuccess(http) <> 1
        Debug CkHttp::ckLastErrorText(http)
        CkHttpRequest::ckDispose(req)
        CkHttp::ckDispose(http)
        ProcedureReturn
    EndIf

    json.i = CkJsonObject::ckCreate()
    If json.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckLoad(json,CkHttpResponse::ckBodyStr(resp))
    CkJsonObject::setCkEmitCompact(json, 0)

    ;  A sample JSON response is shown below..
    Debug CkJsonObject::ckEmit(json)
    Debug "Response Status Code: " + Str(CkHttpResponse::ckStatusCode(resp))

    ;  A response code of 200 is success.
    If CkHttpResponse::ckStatusCode(resp) = 200
        ;  Show a few values from the JSON..
        Debug "first_name: " + CkJsonObject::ckStringOf(json,"response_data.first_name")
        Debug "last_name: " + CkJsonObject::ckStringOf(json,"response_data.last_name")

        ;  Iterate over the bundles.
        i.i = 0
        numBundles.i = CkJsonObject::ckSizeOfArray(json,"response_data.bundles")
        While i < numBundles
            CkJsonObject::setCkI(json, i)

            Debug "Bundle: " + CkJsonObject::ckStringOf(json,"response_data.bundles[i].name")
            i = i + 1
        Wend
    EndIf

    CkHttpResponse::ckDispose(resp)

    ;  ----------------------------------------------------
    ;  Sample JSON response for /getMember
    ;  ----------------------------------------------------

    ;  {
;   "response_code": "200",
    ;    "response_message": "",
    ;    "response_data": {
;     "member_id": 59,
    ;      "first_name": "Jim",
    ;      "last_name": "Smith",
    ;      "is_complimentary": "false",
    ;      "registered": "2003-08-08 00:00:00",
    ;      "cancellation_date": "",
    ;      "last_logged_in": "2017-04-28 16:26:06",
    ;      "last_updated": "2017-04-28 16:26:06",
    ;      "days_as_member": 5013,
    ;      "status": "1",
    ;      "status_name": "Active",
    ;      "membership_level": "12",
    ;      "membership_level_name": "Expert Instructor",
    ;      "username": "JSmith",
    ;      "email": "some_member@somewhere.com",
    ;      "password": null,
    ;      "phone": "(618) 555-5555",
    ;      "billing_address": "555 Shady Lane",
    ;      "billing_city": "Wheaton",
    ;      "billing_state": "IL",
    ;      "billing_zip": "60187",
    ;      "billing_country": "United States",
    ;      "shipping_address": "555 Shady Lane",
    ;      "shipping_city": "Wheaton",
    ;      "shipping_state": "IL",
    ;      "shipping_zip": "60187",
    ;      "shipping_country": "United States",
    ;      "bundles": [
    ;        {
;         "id": "6",
    ;          "name": "ABC Bundle",
    ;          "is_complimentary": "false",
    ;          "days_with_bundle": 2758,
    ;          "status": "1",
    ;          "status_name": "Active",
    ;          "date_added": "2009-10-10 00:00:00",
    ;          "last_updated": "2017-03-26 13:00:30"
    ;        },
    ;        {
;         "id": "8",
    ;          "name": "XZ 2.0 Software License",
    ;          "is_complimentary": "false",
    ;          "days_with_bundle": 2758,
    ;          "status": "1",
    ;          "status_name": "Active",
    ;          "date_added": "2009-10-10 00:00:00",
    ;          "last_updated": "2017-03-26 13:00:30"
    ;        }
    ;      ],
    ;      "custom_fields": [
    ;        {
;         "id": 1,
    ;          "name": "Class Location:",
    ;          "value": ""
    ;        },
    ;        {
;         "id": 2,
    ;          "name": "Company",
    ;          "value": "Acme Interiors Inc"
    ;        },
    ;        {
;         "id": 3,
    ;          "name": "Referred by:",
    ;          "value": ""
    ;        },
    ;        {
;         "id": 4,
    ;          "name": "Sound Analysis Equipment",
    ;          "value": "AudioTools Sound Analyzer with HAA multi mic Kit"
    ;        },
    ;        {
;         "id": 5,
    ;          "name": "HAA Member Number",
    ;          "value": "22222222"
    ;        },
    ;        {
;         "id": 6,
    ;          "name": "Alumni Class Dates",
    ;          "value": ""
    ;        }
    ;      ]
    ;    }
    ;  }
    ; 


    CkHttpRequest::ckDispose(req)
    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(json)


    ProcedureReturn
EndProcedure

 

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