curl https://api.46elks.com/a1/subaccounts \
-u <Username>:<API Password> \
-d name=CompanyXYZ \
-d usagelimit=9000000
import HTTPotion.base
authdata = [basic_auth: {'',
request = %{
"name" => "CompanyXYZ",
"usagelimit" => "9000000"
}
request_data = URI.encode_query(request)
HTTPotion.start
HTTPotion.post("https://api.46elks.com/a1/subaccounts",
[body: request_data , ibrowse: authdata]
)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
public class UnirestSendcalls {
public static void main(String[] args) {
try {
System.out.println("Sending calls");
HttpResponse response = Unirest.post("https://api.46elks.com/a1/subaccounts")
.basicAuth("","")
.field("usagelimit", "9000000")
.field("name", "CompanyXYZ")
.asString();
System.out.println(response.getBody());
}
catch (Exception e){
System.out.println(e);
}
}
}
function allocatenumber ($calls) {
$username = "USERNAME";
$password = "PASSWORD";
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Authorization: Basic '.
base64_encode($username.':'.$password). "\r\n".
"Content-type: application/x-www-form-urlencoded\r\n",
'content' => http_build_query($calls,'','&'),
'timeout' => 10
)));
$response = file_get_contents("https://api.46elks.com/a1/subaccounts",
false, $context);
if (!strstr($http_response_header[0],"200 OK"))
return $http_response_header[0];
return $response;
}
$number = array(
"name" => "CompanyXYZ",
"usagelimit" => "9000000"
);
echo allocatenumber($number);
import requests
auth = (
'',
''
)
fields = {
'name': 'CompanyXYZ',
'usagelimit': '9000000'
}
response = requests.post(
"https://api.46elks.com/a1/subaccounts",
data=fields,
auth=auth
)
print(response.text)
require 'net/http'
uri = URI('https://api.46elks.com/a1/subaccounts')
req = Net::HTTP::Post.new(uri)
req.basic_auth '', ''
req.set_form_data(
:name => 'CompanyXYZ',
:usagelimit => '9000000'
)
res = Net::HTTP.start(
uri.host,
uri.port,
:use_ssl => uri.scheme == 'https') do |http|
http.request req
end
puts res.body