cURL Java Unirest NodeJs Request Objective C PHP Python
Copy curl --location --request GET 'http://api.iapp.co.th/qa-generator-th?text=ผมพูดง่วงมาก&apikey={Your API KEY}'
Copy Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.get("http://api.iapp.co.th/qa-generator-th?text=ผมพูดง่วงมาก&apikey={Your API KEY}")
.asString();
Copy var request = require('request');
var options = {
'method': 'GET',
'url': 'http://api.iapp.co.th/qa-generator-th?text=ผมพูดง่วงมาก&apikey={Your API KEY}',
'headers': {
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Copy #import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://api.iapp.co.th/qa-generator-th?text=%E0%B8%9C%E0%B8%A1%E0%B8%9E%E0%B8%B9%E0%B8%94%E0%B8%87%E0%B9%88%E0%B8%A7%E0%B8%87%E0%B8%A1%E0%B8%B2%E0%B8%81&apikey={Your API KEY}"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} 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);
Copy <?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://api.iapp.co.th/qa-generator-th?text=%E0%B8%9C%E0%B8%A1%E0%B8%9E%E0%B8%B9%E0%B8%94%E0%B8%87%E0%B9%88%E0%B8%A7%E0%B8%87%E0%B8%A1%E0%B8%B2%E0%B8%81&apikey={Your API KEY}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Copy import requests
url = "http://api.iapp.co.th/qa-generator-th?text=ผมพูดง่วงมาก&apikey={Your API KEY}"
payload={}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)