Api Kullanım Örnekleri

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://wa.teknoltan.com/api/private/?apikey=YOUR__APIKEY",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array('phone' => '90530********','text' => 'MESSAGE'),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


//RESPONSE ////////

{
"status": "success",
"phone": "90530********",
"result": "send [2]90530********",
"message": "MESSAGE"
}
import Foundation

var semaphore = DispatchSemaphore (value: 0)

let parameters = [
[
"key": "phone",
"value": "PHONE_NUMBER",
"type": "text"
],
[
"key": "title",
"value": "MESSAGE_TITLE",
"type": "text"
],
[
"key": "text",
"value": "MESSAGE_TEXT",
"type": "text"
]] as [[String : Any]]

let boundary = "Boundary-\(UUID().uuidString)"
var body = ""
var error: Error? = nil
for param in parameters {
if param["disabled"] == nil {
let paramName = param["key"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
let paramType = param["type"] as! String
if paramType == "text" {
let paramValue = param["value"] as! String
body += "\r\n\r\n\(paramValue)\r\n"
} else {
let paramSrc = param["src"] as! String
let fileData = try NSData(contentsOfFile:paramSrc, options:[]) as Data
let fileContent = String(data: fileData, encoding: .utf8)!
body += "; filename=\"\(paramSrc)\"\r\n"
+ "Content-Type: \"content-type header\"\r\n\r\n\(fileContent)\r\n"
}
}
}
body += "--\(boundary)--\r\n";
let postData = body.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://wa.teknoltan.com/api/v1/?apikey=")!,timeoutInterval: Double.infinity)
request.addValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}

task.resume()
semaphore.wait()
wget --no-check-certificate --quiet \
--method POST \
--timeout=0 \
--header '' \
--body-data 'phone=PHONE_NUMBER&title=MESSAGE_TITLE&text=MESSAGE_TEXT' \
'https://wa.teknoltan.com/api/v1/?apikey='
http --ignore-stdin --form --follow --timeout 3600 POST wa.teknoltan.com/api/v1/ 'apikey'=='' \
'phone'='PHONE_NUMBER' \
'title'='MESSAGE_TITLE' \
'text'='MESSAGE_TEXT'
require "uri"
require "net/http"

url = URI("https://wa.teknoltan.com/api/v1/?apikey=")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
form_data = [['phone', 'PHONE_NUMBER'],['title', 'MESSAGE_TITLE'],['text', 'MESSAGE_TEXT']]
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body
import requests

url = "https://wa.teknoltan.com/api/v1/?apikey="

payload = {'phone': 'PHONE_NUMBER',
'title': 'MESSAGE_TITLE',
'text': 'MESSAGE_TEXT'}
files = [

]
headers= {}

response = requests.request("POST", url, headers=headers, data = payload, files = files)

print(response.text.encode('utf8'))
import http.client
import mimetypes
conn = http.client.HTTPSConnection("wa.teknoltan.com")
dataList = []
boundary = 'wL36Yn8afVp8Ag7AmP8qZ0SA4n1v9T'
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=phone;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("PHONE_NUMBER")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=title;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("MESSAGE_TITLE")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=text;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("MESSAGE_TEXT")
dataList.append('--'+boundary+'--')
dataList.append('')
body = '\r\n'.join(dataList)
payload = body
headers = {
'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
}
conn.request("POST", "/api/v1/?apikey=", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()
$stringHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$stringHeader.Name = "phone"
$StringContent = [System.Net.Http.StringContent]::new("PHONE_NUMBER")
$StringContent.Headers.ContentDisposition = $stringHeader
$multipartContent.Add($stringContent)

$stringHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$stringHeader.Name = "title"
$StringContent = [System.Net.Http.StringContent]::new("MESSAGE_TITLE")
$StringContent.Headers.ContentDisposition = $stringHeader
$multipartContent.Add($stringContent)

$stringHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$stringHeader.Name = "text"
$StringContent = [System.Net.Http.StringContent]::new("MESSAGE_TEXT")
$StringContent.Headers.ContentDisposition = $stringHeader
$multipartContent.Add($stringContent)

$body = $multipartContent

$response = Invoke-RestMethod 'https://wa.teknoltan.com/api/v1/?apikey=' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://wa.teknoltan.com/api/v1/?apikey=');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->addForm(array(
'phone' => 'PHONE_NUMBER',
'title' => 'MESSAGE_TITLE',
'text' => 'MESSAGE_TEXT'
), array(

));
$request->setBody($body);
$request->setOptions(array());

$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://wa.teknoltan.com/api/v1/?apikey=');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->addPostParameter(array(
'phone' => 'PHONE_NUMBER',
'title' => 'MESSAGE_TITLE',
'text' => 'MESSAGE_TEXT'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}

function VERIFY_API($PHONE_NUMBER,$VERIFY_CODE){
$API_KEY = "YOUR API KEY";
$COMPANY_NAME = "YOUR COMPANY NAME";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://wa.teknoltan.com/api/v1/?apikey=".$API_KEY,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array('phone' => $PHONE_NUMBER,'title' => $COMPANY_NAME,'text' => $VERIFY_CODE),
));
$response = curl_exec($curl);
curl_close($curl);
return $response;
}

echo(VERIFY_API("90530xxxxxxx",rand(100000,999999)));
open Lwt
open Cohttp
open Cohttp_lwt_unix

let parameters = [|
[| ("name", "phone"); ("value", "PHONE_NUMBER") |];
[| ("name", "title"); ("value", "MESSAGE_TITLE") |];
[| ("name", "text"); ("value", "MESSAGE_TEXT") |]
|];;
let boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW";;
let postData = ref "";;

for x = 0 to Array.length parameters - 1 do
let (_, paramName) = parameters.(x).(0) in
let (paramType, _) = parameters.(x).(1) in
let accum = "--" ^ boundary ^ "\r\n" ^ "Content-Disposition: form-data; name=\"" ^ paramName ^ "\"" in
if paramType = "value" then (
let (_, paramValue) = parameters.(x).(1) in
postData := !postData ^ accum ^ "\r\n\r\n" ^ paramValue ^ "\r\n";
)
else if paramType = "fileName" then (
let (_, filepath) = parameters.(x).(1) in
postData := !postData ^ accum ^ "; filename=\""^ filepath ^"\"\r\n";
let ch = open_in filepath in
let fileContent = really_input_string ch (in_channel_length ch) in
close_in ch;
postData := !postData ^ "Content-Type: {content-type header}\r\n\r\n"^ fileContent ^"\r\n";
)
done;;
postData := !postData ^ "--" ^ boundary ^ "--"

let reqBody =
let uri = Uri.of_string "https://wa.teknoltan.com/api/v1/?apikey=" in
let headers = Header.init ()
|> fun h -> Header.add h "content-type" "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
in
let body = Cohttp_lwt.Body.of_string !postData in

Client.call ~headers ~body `POST uri >>= fun (resp, body) ->
body |> Cohttp_lwt.Body.to_string >|= fun body -> body

let () =
let respBody = Lwt_main.run reqBody in
print_endline (respBody)
#import

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://wa.teknoltan.com/api/v1/?apikey="]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSArray *parameters = @[
@{ @"name": @"phone", @"value": @"PHONE_NUMBER" },
@{ @"name": @"title", @"value": @"MESSAGE_TITLE" },
@{ @"name": @"text", @"value": @"MESSAGE_TEXT" }
];

NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
NSError *error;
NSMutableString *body = [NSMutableString string];

for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
var unirest = require('unirest');
var req = unirest('POST', 'https://wa.teknoltan.com/api/v1/?apikey=')
.field('phone', 'PHONE_NUMBER')
.field('title', 'MESSAGE_TITLE')
.field('text', 'MESSAGE_TEXT')
.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.raw_body);
});
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://wa.teknoltan.com/api/v1/?apikey=',
'headers': {
},
formData: {
'phone': 'PHONE_NUMBER',
'title': 'MESSAGE_TITLE',
'text': 'MESSAGE_TEXT'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
'method': 'POST',
'hostname': 'wa.teknoltan.com',
'path': '/api/v1/?apikey=',
'headers': {
},
'maxRedirects': 20
};

var req = https.request(options, function (res) {
var chunks = [];

res.on("data", function (chunk) {
chunks.push(chunk);
});

res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});

res.on("error", function (error) {
console.error(error);
});
});

var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"phone\"\r\n\r\nPHONE_NUMBER\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\nMESSAGE_TITLE\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"text\"\r\n\r\nMESSAGE_TEXT\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--";

req.setHeader('content-type', 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');

req.write(postData);

req.end();
var data = new FormData();
data.append("phone", "PHONE_NUMBER");
data.append("title", "MESSAGE_TITLE");
data.append("text", "MESSAGE_TEXT");

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://wa.teknoltan.com/api/v1/?apikey=");

xhr.send(data);
var form = new FormData();
form.append("phone", "PHONE_NUMBER");
form.append("title", "MESSAGE_TITLE");
form.append("text", "MESSAGE_TEXT");

var settings = {
"url": "https://wa.teknoltan.com/api/v1/?apikey=",
"method": "POST",
"timeout": 0,
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};

$.ajax(settings).done(function (response) {
console.log(response);
});
var formdata = new FormData();
formdata.append("phone", "PHONE_NUMBER");
formdata.append("title", "MESSAGE_TITLE");
formdata.append("text", "MESSAGE_TEXT");

var requestOptions = {
method: 'POST',
body: formdata,
redirect: 'follow'
};

fetch("https://wa.teknoltan.com/api/v1/?apikey=", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Unirest.setTimeouts(0, 0);
HttpResponse response = Unirest.post("https://wa.teknoltan.com/api/v1/?apikey=")
.multiPartContent() .field("phone", "PHONE_NUMBER")
.field("title", "MESSAGE_TITLE")
.field("text", "MESSAGE_TEXT")
.asString();
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("phone", "PHONE_NUMBER")
.addFormDataPart("title", "MESSAGE_TITLE")
.addFormDataPart("text", "MESSAGE_TEXT")
.build();
Request request = new Request.Builder()
.url("https://wa.teknoltan.com/api/v1/?apikey=")
.method("POST", body)
.build();
Response response = client.newCall(request).execute();
POST /api/v1/?apikey= HTTP/1.1
Host: wa.teknoltan.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="phone"

PHONE_NUMBER
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="title"

MESSAGE_TITLE
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="text"

MESSAGE_TEXT
----WebKitFormBoundary7MA4YWxkTrZu0gW
package main

import (
"fmt"
"bytes"
"mime/multipart"
"net/http"
"io/ioutil"
)

func main() {

url := "https://wa.teknoltan.com/api/v1/?apikey="
method := "POST"

payload := &bytes.Buffer{}
writer := multipart.NewWriter(payload)
_ = writer.WriteField("phone", "PHONE_NUMBER")
_ = writer.WriteField("title", "MESSAGE_TITLE")
_ = writer.WriteField("text", "MESSAGE_TEXT")
err := writer.Close()
if err != nil {
fmt.Println(err)
}


client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)

if err != nil {
fmt.Println(err)
}
req.Header.Set("Content-Type", writer.FormDataContentType())
res, err := client.Do(req)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)

fmt.Println(string(body))
}
curl --location --request POST 'https://wa.teknoltan.com/api/v1/?apikey=' \
--form 'phone=PHONE_NUMBER' \
--form 'title=MESSAGE_TITLE' \
--form 'text=MESSAGE_TEXT'
var client = new RestClient("https://wa.teknoltan.com/api/v1/?apikey=");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AlwaysMultipartFormData = true;
request.AddParameter("phone", "PHONE_NUMBER");
request.AddParameter("title", "MESSAGE_TITLE");
request.AddParameter("text", "MESSAGE_TEXT");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://wa.teknoltan.com/api/v1/?apikey=");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_mime *mime;
curl_mimepart *part;
mime = curl_mime_init(curl);
part = curl_mime_addpart(mime);
curl_mime_name(part, "phone");
curl_mime_data(part, "PHONE_NUMBER", CURL_ZERO_TERMINATED);
part = curl_mime_addpart(mime);
curl_mime_name(part, "title");
curl_mime_data(part, "MESSAGE_TITLE", CURL_ZERO_TERMINATED);
part = curl_mime_addpart(mime);
curl_mime_name(part, "text");
curl_mime_data(part, "MESSAGE_TEXT", CURL_ZERO_TERMINATED);
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
res = curl_easy_perform(curl);
curl_mime_free(mime);
}
curl_easy_cleanup(curl);