InTime API - Exempel kod



Similar documents
Using ilove SharePoint Web Services Workflow Action

This section will describe the different functions that can be used by the Interspire Marketer XML API.

Technical documentation

MSDG Services Integration Document Draft Ver 1.2

MAIL1CLICK API - rel 1.35

SIM Configuration Guide. February 2015 Version 1 Document Reference: 8127

NASDAQ Global Index Watch (GIW) Secure Web Service 2.0 Access

Interface Programmera mot interface Johan Eliasson Johan Eliasson Interface kan bryta beroendekedjor Skriv generell kod «Type» Class2 Interface

ResellerPlus - Bulk Http API Specification. (This Document gives details on how to send messages via the Bulk HTTP API for the RouteSms SMPP System)

AMD Telecom SMS GATEWAY HTTP API INTERFACE. Technical Specifications

Developing Mobile Services for Joomla! 1.5

A RESTful Web Service Interface to the ATLAS COOL Database

Copyright Notice. ISBN: N/A SWsoft Sunrise Valley Drive Suite 600 Herndon VA USA Phone: +1 (703) Fax: +1 (703)

Threat Advisory: Atlassian Crowd (CVE )

Capturx for SharePoint 2.0: Notification Workflows

Riverbed Cascade Shark Common REST API v1.0

Chapter 22 How to send and access other web sites

E-invoice manual Instruction for a client implementation of the B2B web service

Installation and Integration Manual TRANZILA Secure 5

HTTP Application Programming Interface

Viktigaste uppgift: Web Browser SSO

THE CHALLENGE OF ADMINISTERING WEBSITES OR APPLICATIONS THAT REQUIRE 24/7 ACCESSIBILITY

public void setusername(string username) { this.username = username; } public void setname(string name) { this.name = name; }

Web Services Tutorial

07/04/2014 NOBIL API. Version 3.0. Skåland Webservice Side 1 / 16

Paynow 3rd Party Shopping Cart or Link Integration Guide

Credit Card Transactions

About This Document 3. Integration and Automation Capabilities 4. Command-Line Interface (CLI) 8. API RPC Protocol 9.

Contents. 2 Alfresco API Version 1.0

Cloud Elements ecommerce Hub Provisioning Guide API Version 2.0 BETA

Fairsail REST API: Guide for Developers

FileMaker Server 13. Custom Web Publishing with PHP

How To Use Blackberry Web Services On A Blackberry Device

Message Containers and API Framework

ipayment Gateway API (IPG API)

Technical Specification Normal SMS gateway

Version 1.0. ASAM CS Single Sign-On

Technical Specification Premium SMS gateway

Consuming a Web Service(SOAP and RESTful) in Java. Cheat Sheet For Consuming Services in Java

PRTK. Password Recovery ToolKit EFS (Encrypting File System)

Unifaun XMLPosting

Projektet Computer: Specifikation. Objektorienterad modellering och diskreta strukturer / design. Projektet Computer: Data. Projektet Computer: Test

See the Developer s Getting Started Guide for an introduction to My Docs Online Secure File Delivery and how to use it programmatically.

FIREEYE APP FOR SPLUNK ENTERPRISE 6.X. Configuration Guide Version 1.3 SECURITY REIMAGINED

Cite My Data M2M Service Technical Description

EMS E-COMMERCE GATEWAY API TECHNICAL INSTALLATION MANUAL FEBRUARY 2016

Spring Design ScreenShare Service SDK Instructions

UFTP AUTHENTICATION SERVICE

SINGLE SIGNON FUNCTIONALITY IN HATS USING MICROSOFT SHAREPOINT PORTAL

NASDAQ Global Index Watch (GIW) Secure Web Service 2.1 Access

Wind River. Intelligent Device Platform XT EMS Profile EMS DEVICE MANAGEMENT USER'S GUIDE WIND RIVER 1.0

Spryng Making Business Mobile Mobile Terminated Premium SMS Gateway. Contents:

HTTP/HTTPS/XML API Hand Book

REST web services. Representational State Transfer Author: Nemanja Kojic

Ciphermail Gateway PDF Encryption Setup Guide

WINDOWS PRESENTATION FOUNDATION LEKTION 3

Spryng Making Business Mobile (0) Spryng Headquarters: Herengracht BW Amsterdam - The Netherlands

Directories Web Services

Three Step Redirect API V2.0 Patent Pending

VIDEO intypedia007en LESSON 7: WEB APPLICATION SECURITY - INTRODUCTION TO SQL INJECTION TECHNIQUES. AUTHOR: Chema Alonso

FileMaker Server 12. Custom Web Publishing with PHP

Security API Cookbook

GTX Mobile Messaging SMS Gateway Interface Simple HTTP API Manual

TWO-WAY & SMS MESSAGING SMS WEB SERVICE. Product White Paper. Website: Telephone: enquiries@m-science.

Onset Computer Corporation

GetLibraryUserOrderList

SmarterMeasure Inbound Single Sign On (SSO) Version 1.3 Copyright 2010 SmarterServices, LLC / SmarterServices.com PO Box , Deatsville, AL 36022

WebSocket Server. To understand the Wakanda Server side WebSocket support, it is important to identify the different parts and how they interact:

Integrating XACML into JAX-WS and WSIT

Startup guide for Zimonitor

IoT-Ticket.com. Your Ticket to the Internet of Things and beyond. IoT API

Webair CDN Secure URLs

Three Step Redirect API

Sample HP OO Web Application

CTIS 256 Web Technologies II. Week # 1 Serkan GENÇ

API documentation - 1 -

NYSP Web Service FAQ

Create you first HTTP Handler in ASP.NET 3.5

Creating Form Rendering ASP.NET Applications

GATEWAY FREEDOM INTEGRATION GUIDE

Web Development using PHP (WD_PHP) Duration 1.5 months

Inventory Update API User Documentation

API Reference. Nordisk e-handel AB. Version 24

Brekeke PBX Web Service

SVEA HOSTED SERVICE SPECIFICATION V1.13

Setup Corporate (Microsoft Exchange) . This tutorial will walk you through the steps of setting up your corporate account.

Pervasive Data Integrator. Oracle CRM On Demand Connector Guide

Getting Started with the icontact API

Brekeke PBX Version 3 Web Service Developer s Guide Brekeke Software, Inc.

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

FireEye App for Splunk Enterprise

Använd SAS för att bearbeta och analysera ditt data i Hadoop

Documentation for the SMSWay API v1.5. API for SMSWay Gateway. Documentation for the SMSWay API v

vcommander will use SSL and session-based authentication to secure REST web services.

App Note. VoxStack GSM Gateway API

Safeguard Ecommerce Integration / API

Transcription:

InTime API - Exempel kod Exempel kod för att anropa Intime HTTP API. Översikt funktioner C# Meddelanden PHP Meddelanden 1

C# - Meddelanden En generell klass för att anropa Intime API som används i samtliga exempel. public class IntimeAPI private string serviceurl get; set; private string user get; set; private string hash get; set; public IntimeAPI(string serviceurl, string user, string hash) this.serviceurl = serviceurl; this.user = user; this.hash = hash; public string DeleteMessage(string xml) return ServiceRequest(string.Format("0/1?user=2&hash=3", this.serviceurl, "delete.ashx", this.user, this.hash), xml); public string SendMessage(string xml) return ServiceRequest(string.Format("0/1?user=2&hash=3", this.serviceurl, "create.ashx", this.user, this.hash), xml); private string ServiceRequest(string url, string xml) byte[] bytearray = StrToByteArray(xml); HttpWebRequest myreq = (HttpWebRequest)WebRequest.Create(url); myreq.method = "POST"; myreq.contenttype = "text/xml"; myreq.contentlength = bytearray.length; myreq.credentials = System.Net.CredentialCache.DefaultNetworkCredentials; Stream newstream = myreq.getrequeststream(); newstream.write(bytearray, 0, bytearray.length); newstream.close(); HttpWebResponse myresponse = (HttpWebResponse)myReq.GetResponse(); Stream stream = myresponse.getresponsestream(); StreamReader reader = new StreamReader(stream); string result = reader.readtoend(); return result; private static byte[] StrToByteArray(string str) System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); return encoding.getbytes(str); 2

string serviceurl = https://... ; string username = username ; string hash= hash ; IntimeAPI api = new IntimeAPI(serviceurl, username, hash); StringBuilder xml_send = new StringBuilder(); xml_send.append("<?xml version=\"1.0\" encoding=\"iso-8859-1\""); xml_send.append("<message>"); xml_send.append(" <flash>0</flash>"); xml_send.append(" <multisms>0</multisms>"); xml_send.append(" <senddate>2012-02-29t14:41:00</senddate>"); xml_send.append(" <sendertitle>simon test</sendertitle>"); xml_send.append(" <body>mitt test meddelande</body>"); xml_send.append(" <statusurl>http://www.kunden.se/status.php</statusurl>"); xml_send.append(" <recipients>"); xml_send.append(" <recipient transid=\"12345678\">0703027930</recipient>"); xml_send.append(" </recipients>"); xml_send.append("</message>"); string response = ; response = api.sendmessage( xml_send.tostring() ); string serviceurl = https://... ; string username = username ; string hash= hash ; IntimeAPI api = new IntimeAPI(serviceurl, username, password); StringBuilder xml_delete = new StringBuilder(); xml_delete.append("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ); xml_delete.append("<message><messageid>2319974</messageid></message>"); string response = ; response = api.deletemessage(xml_delete.tostring()); Skapa en.ashx handler som tolkar ett http post request från intimes servrar. public class Callback : IHttpHandler public void ProcessRequest(HttpContext context) string messageid = context.request.params.get("messageid"); string status = context.request.params.get("status"); string transid = context.request.params.get("transid"); // TODO ADD My internal logic to save status callbacks public bool IsReusable get 3

return false; PHP - Meddelanden En generell klass för att anropa Intime API som används i samtliga exempel. class IntimeAPI private $serviceurl; private $username; private $hash; private $certpath; public function construct( $serviceurl, $username, $hash, $certpath = "" ) // Set parameters $this->serviceurl = $serviceurl; $this->username = $username; $this->hash = $hash; $this->certpath = $certpath; $xml ); $xml ); public function DeleteMessage($xml) return self::servicerequest( $this->serviceurl."/delete.ashx?user=".$this->username."&hash=".$this->hash, public function SendMessage( $xml) return self::servicerequest( $this->serviceurl."/create.ashx?user=".$this->username."&hash=".$this->hash, private function ServiceRequest( $url, $xml ) // Init request $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST' ); curl_setopt($ch, CURLOPT_HTTPHEADER, array("content-type: text/xml","content-length: ".strlen($xml))); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); // Https request if( strstr($url, 'https') ) if( $this->certpath == "" ) curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); else $this->certpath = getcwd(). $this->certpath; if(!file_exists($this->certpath) ) Throw new Exception("Could not locate certificate file! ". $this->certpath); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_CAINFO, $this->certpath ); 4

// Excecute request $response = curl_exec($ch); // Check for error in request $error = curl_error($ch); if($error!= "" ) Throw new Exception("Request curl error : ". $error ); // Return response return $response; // Intime API server url and user information $serviceurl = "https://..."; $username = "myusername"; $hash = "hash"; // Skapa en ny instance av API classen $intimeapi = new IntimeAPI( $serviceurl,$username,$hash); $xml = '<?xml version="1.0" encoding= iso-8859-1" <message> <flash>0</flash> <multisms>0</multisms> <senddate></senddate> <sendertitle>my subject</sendertitle> <body>my first message</body> <statusurl></statusurl> <recipients> <recipient transid="12345">070123456</recipient> </recipients> </message>'; // Send message $response = $intimeapi->sendmessage( $xml ); // Intime API server url and user information $serviceurl = "https://..."; $username = "myusername"; $hash = "hash"; // Skapa en ny instance av API classen $intimeapi = new IntimeAPI( $serviceurl,$username,$hash); 5

$xml_delete = '<?xml version="1.0" encoding= iso-8859-1"<message><messageid>2319974</messageid></message>'; // Delete message $response = $intimeapi->deletemessage( $xml_delete ); Skapa t.ex.en php fil som tolkar ett http post request från intimes servrar. Sidan måste vara tillgänglig på den adress som definierades när man skickade meddelandet i statusurl taggen. // mysatuscallback.php if( isset($_post['messageid'],$_post['status'],$_post['transid']) ) // TODO add my status callback code else header("status: 404 Not Found"); 6