Jetzt testen


Probier es aus! Ein Anruf an die 01579-9912345 genügt und Dein Anruf erscheint sofort auf dieser Website - Live!

Deine Rufnummer erscheint hier

Eingegangene Anrufe erfolgten von

Anrufernummer Angerufene Nummer Uhrzeit

Um sipgate.io zu testen, kannst Du die URL https://demo.sipgate.io/ in Deinem Account eintragen und anschließend Deine Nummer anrufen. Du solltest Deinen Anruf in Echtzeit auf dieser Seite sehen!

Codebeispiele


Alles was Du benötigst, ist ein Webservice, der die POST Parameter from, to und direction auswertet:

var app = require('express')();
var bodyParser = require('body-parser');

app.use(bodyParser.urlencoded({ extended: false }));

app.post("/", function (request, response) {
	var from = request.body.from;
	var to = request.body.to;
	var direction = request.body.direction;

	console.log("from: " + from);
	console.log("to: " + to);
	console.log("direction: " + direction);

	response.send("So Long, and Thanks for All the Fish!");
});

app.listen(3000);
;; This assumes you are using leiningen (http://leiningen.org/)
;; You can then run this project via
;; $ lein run
;;
;; For complete example (including project file) please look at
;; https://github.com/sipgate/sipgate.io/tree/master/examples/clojure
;;

(ns sipgateio.server
  (:gen-class))

(use 'ring.adapter.jetty
     'ring.middleware.params)

(defn handler [{params :params}]
  (println (str "Call from " (params "from") " to " (params "to")))
  {:status 200 :body "I love the JVM" })

(defn -main
  [& args]
  (run-jetty (wrap-params handler) {:port 3000}))
;; This example uses hunchentoot as webserver.
;; You can obtain it from http://weitz.de/hunchentoot/
;;
;; If you use quicklisp, you can simply install it by evaluating
;; (ql:quickload "hunchentoot")

(require :hunchentoot)
(use-package :hunchentoot)

(define-easy-handler (incoming-handler :uri "/") (from to)
  (log-message* :info "got call from ~a to ~a~%" from to)
  "girls just wanna defun!")

(defparameter *server* (start (make-instance 'easy-acceptor
					     :port 3000)))

;; to stop server: (stop *server*)
package main

import (
	"fmt"
	"net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()

	from := r.Form.Get("from")
	to := r.Form.Get("to")
	direction := r.Form.Get("direction")

	fmt.Printf("from: %s\n", from)
	fmt.Printf("to: %s\n", to)
	fmt.Printf("direction: %s\n", direction)

	fmt.Fprintf(w, "El Barto was here!")
}

func main() {
	http.HandleFunc("/", handler)
	http.ListenAndServe(":3000", nil)
}
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.util.ArrayList;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;

public class server {

	public static void main(String[] args) throws Exception {
		// Create server with port 3000
		HttpServer httpserver = HttpServer.create(new InetSocketAddress(3000), 0);
		httpserver.createContext("/", new MyHandler());
		// creates a default executor
		httpserver.setExecutor(null);
		httpserver.start();

		System.out.println("Server running....");
		System.out.println("Press CTRL+C to stop the server");
	}

	static class MyHandler implements HttpHandler {
		public void handle(HttpExchange httpexchange) throws IOException {
			//Read HTTP header
			InputStream is = httpexchange.getRequestBody();
			int charValue;

			ArrayList chars = new ArrayList();

			// Print data from header
			while ((charValue = is.read()) != -1) {
				chars.add((char) charValue);
				System.out.print((char) charValue);
			}

			StringBuilder builder = new StringBuilder(chars.size());

			//Build string from characters
			for (Character ch : chars) {
				builder.append(ch);
			}

			//Check which number is calling
			if (builder.toString().contains("from=491234567890"))
				System.out.println("\nDo something here");

			System.out.println("\n200 OK");
			OutputStream os = httpexchange.getResponseBody();
			os.close();
		}
	}

}
#!/usr/bin/env perl

use Mojolicious::Lite;

post '/' => sub {
	my $c = shift;

	my $from = $c->param('from');
	my $to = $c->param('to');
	my $direction = $c->param('direction');

	app->log->debug("from: '$from'");
	app->log->debug("to: '$to'");
	app->log->debug("direction: '$direction'");

	$c->render(text => 'We ♥ perl!');
};

app->start();
// Prepare variables for easier handling
$fromNumber = $_POST['from'];      // the number of the caller
$toNumber   = $_POST['to'];        // the number on which the call was received on
$direction  = $_POST['direction']; // the direction of the call
$timestamp  = date("d.m.Y H:i:s"); // a timestamp for the log so that calls can be uniquely identified

// build the log row, example:
// 17.09.2014 10:05:25 - from 4921100000000 to 4921100000000 direction in
$logRow = $timestamp . " - from " . $fromNumber . " to " . $toNumber . " direction " . $direction . PHP_EOL;

// append the log row to the callog.txt file, make sure this file is writeable (e.g. create the file and chmod 777 it)
file_put_contents("callog.txt",$logRow,FILE_APPEND);

die("Thanks - here's a motivational squirrel for you! https://www.youtube.com/watch?v=m3d03-sSiBE");
#!/usr/bin/env python

from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
import urlparse
import logging

logging.basicConfig(level=logging.DEBUG)

class MegaAwesomePythonServer(BaseHTTPRequestHandler):

    def do_POST(self):
        length = int(self.headers.getheader('Content-Length'))
        data = urlparse.parse_qs(self.rfile.read(length))

        logging.debug("from: " + data.get("from")[0])
        logging.debug("to: " + data.get("to")[0])
        logging.debug("direction: " + data.get("direction")[0])

        self.send_response(200)
        self.end_headers()
        self.wfile.write("http://xkcd.com/353/")


server = HTTPServer(('', 3000), MegaAwesomePythonServer)
server.serve_forever()
require 'sinatra'

set :port, 3000

post '/' do
  logger.info "from: #{params[:from]}"
  logger.info "to: #{params[:to]}"
  logger.info "direction: #{params[:direction]}"
end
import org.http4s.server.blaze.BlazeServer
import org.http4s.server.HttpService
import org.http4s.dsl._
import java.net.URLDecoder

object Server extends App {
  def parseBody(body: String) = {
    body.split("&").map( s => {
      val m =  s.split("=", 2).map(s => URLDecoder.decode(s, "UTF-8"))
      m(0) -> m(1)
    }).toMap
  }

  val service: HttpService = {
    case req @ POST -> Root =>
      val data = parseBody(text(req).run)
      println("from: " + data.getOrElse("from", ""))
      println("to: " + data.getOrElse("to", ""))
      println("direction: " + data.getOrElse("direction", ""))
      Ok("roger that")
  }

  BlazeServer.newBuilder.mountService(service, "/").run()
}
#!/bin/sh

while true; do
	echo -e "HTTP/1.1 200 OK\n\nAll your base are belong to us" | nc -l -p 3000
done | tee api.log
Fork me on GitHub