Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicPythonRubySQL ServerSwiftTclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcel

PHP ActiveX Examples


ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
Facebook
Firebase
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
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
VoiceBase
Walmart
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(PHP ActiveX) REST through HTTP Proxy

Demonstrates how to connect through an HTTP proxy to make REST API calls.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

<?php

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

//  This example connects to a REST server through an HTTP proxy.
//  It will connect to the Amazon AWS service for this example.
$rest = new COM("Chilkat_9_5_0.Rest");
$socket = new COM("Chilkat_9_5_0.Socket");

//  Set the HTTP proxy domain or IP address, and port.
$socket->HttpProxyHostname = '192.168.1.100';
$socket->HttpProxyPort = 8088;
//  Other properties exist for specifying a proxy login, password, and authentication method (such as NTLM),
//  but these are not used in this example.

//  Connect through the HTTP proxy to the Amazon AWS server for the S3 service.
$bTls = 1;
$port = 443;
$maxWaitMs = 5000;
$success = $socket->Connect('s3.amazonaws.com',$port,$bTls,$maxWaitMs);
if ($success != 1) {
    print 'Connect Failure Error Code: ' . $socket->ConnectFailReason . "\n";
    print $socket->LastErrorText . "\n";
    exit;
}

//  Use the proxied TLS connection:
$success = $rest->UseConnection($socket,1);
if ($success != 1) {
    print $rest->LastErrorText . "\n";
    exit;
}

//  Provide AWS credentials for the REST call.
$authAws = new COM("Chilkat_9_5_0.AuthAws");
$authAws->AccessKey = 'AWS_ACCESS_KEY';
$authAws->SecretKey = 'AWS_SECRET_KEY';
$authAws->ServiceName = 's3';
$success = $rest->SetAuthAws($authAws);

//  List all buckets for the account...
$responseXml = $rest->fullRequestNoBody('GET','/');
if ($rest->LastMethodSuccess != 1) {
    print $rest->LastErrorText . "\n";
    exit;
}

$xml = new COM("Chilkat_9_5_0.Xml");
$success = $xml->LoadXml($responseXml);

//  Show the full XML returned.
print $xml->getXml() . "\n";

//  Iterate over the buckets, showing each bucket name.
$success = $xml->FindChild2('Buckets');
if ($xml->FirstChild2() == 1) {
    print $xml->getChildContent('Name') . "\n";
    while (($xml->NextSibling2() == 1)) {
        print $xml->getChildContent('Name') . "\n";
    }

}

//  Move the internal pointer back to the root node.
$xml->GetRoot2();

?>

 

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