curl --request GET \
--url 'https://ruangapi.com/api/v1/cities?province=1&id=&q=' \
--header 'accept: application/json' \
--header 'authorization: your-api-key'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://ruangapi.com/api/v1/cities?province=1&id=&q=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"authorization: your-api-key"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
var unirest = require("unirest");
var req = unirest("GET", "https://ruangapi.com/api/v1/cities");
req.query({
"province": "1",
"id": "",
"q": ""
});
req.headers({
"authorization": "your-api-key",
"accept": "application/json"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
HttpResponse<String> response = Unirest.get("https://ruangapi.com/api/v1/cities?province=1&id=&q=")
.header("authorization", "your-api-key")
.header("accept", "application/json")
.asString();
import requests
url = "https://ruangapi.com/api/v1/cities"
querystring = {"province":"1","id":"","q":""}
headers = {
'authorization': "your-api-key",
'accept': "application/json"
}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://ruangapi.com/api/v1/cities?province=1&id=&q=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["authorization"] = 'your-api-key'
request["accept"] = 'application/json'
response = http.request(request)
puts response.read_body
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"authorization": @"your-api-key",
@"accept": @"application/json" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://ruangapi.com/api/v1/cities?province=1&id=&q="]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
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;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://ruangapi.com/api/v1/cities?province=1&id=&q="
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("authorization", "your-api-key")
req.Header.Add("accept", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}