πEJEMPLOS
Ejemplos
Eche un vistazo a cΓ³mo podrΓa llamar a este mΓ©todo utilizando diferentes lenguajes de programaciΓ³n, aquΓ hay unos ejemplos en diferente lenguajes.
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api.factiliza.com/pe/v1/dni/info/27427864");
request.Headers.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI3IiwiZW1haWwiOiJhbmdlbGl0b2FsZXgyMDBAZ21haWwuY29tIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiY29uc3VsdG9yIn0.w8DwLqSuge7pO_CjTKliZGoMUyKYs5W-ft0Lz3sowpE");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.factiliza.com/pe/v1/dni/info/27427864',
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',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI3IiwiZW1haWwiOiJhbmdlbGl0b2FsZXgyMDBAZ21haWwuY29tIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiY29uc3VsdG9yIn0.w8DwLqSuge7pO_CjTKliZGoMUyKYs5W-ft0Lz3sowpE'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://api.factiliza.com/pe/v1/dni/info/27427864")
.method("GET", body)
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI3IiwiZW1haWwiOiJhbmdlbGl0b2FsZXgyMDBAZ21haWwuY29tIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiY29uc3VsdG9yIn0.w8DwLqSuge7pO_CjTKliZGoMUyKYs5W-ft0Lz3sowpE")
.build();
Response response = client.newCall(request).execute();
var settings = {
"url": "https://api.factiliza.com/pe/v1/dni/info/27427864",
"method": "GET",
"timeout": 0,
"headers": {
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI3IiwiZW1haWwiOiJhbmdlbGl0b2FsZXgyMDBAZ21haWwuY29tIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiY29uc3VsdG9yIn0.w8DwLqSuge7pO_CjTKliZGoMUyKYs5W-ft0Lz3sowpE"
},
};
$.ajax(settings).done(function (response) {
console.log(response);
});
const axios = require('axios');
let config = {
method: 'get',
maxBodyLength: Infinity,
url: 'https://api.factiliza.com/pe/v1/dni/info/27427864',
headers: {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI3IiwiZW1haWwiOiJhbmdlbGl0b2FsZXgyMDBAZ21haWwuY29tIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiY29uc3VsdG9yIn0.w8DwLqSuge7pO_CjTKliZGoMUyKYs5W-ft0Lz3sowpE'
}
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
import { Component } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
@Component({
selector: 'app-tu-componente',
templateUrl: './tu-componente.component.html',
styleUrls: ['./tu-componente.component.css']
})
export class TuComponenteComponent {
response: any;
constructor(private http: HttpClient) { }
hacerSolicitud() {
const url = 'https://api.factiliza.com/pe/v1/dni/info/27427864';
const headers = new HttpHeaders({
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI3IiwiZW1haWwiOiJhbmdlbGl0b2FsZXgyMDBAZ21haWwuY29tIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiY29uc3VsdG9yIn0.w8DwLqSuge7pO_CjTKliZGoMUyKYs5W-ft0Lz3sowpE'
});
this.http.get(url, { headers }).subscribe(
(response) => {
this.response = response;
console.log(response);
},
(error) => {
console.log(error);
}
);
}
}
import http.client
conn = http.client.HTTPSConnection("api.factiliza.com")
payload = ''
headers = {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI3IiwiZW1haWwiOiJhbmdlbGl0b2FsZXgyMDBAZ21haWwuY29tIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiY29uc3VsdG9yIn0.w8DwLqSuge7pO_CjTKliZGoMUyKYs5W-ft0Lz3sowpE'
}
conn.request("GET", "/pe/v1/dni/info/27427864", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Imports System.Net
Module MainModule
Sub Main()
Dim url As String = "https://api.factiliza.com/pe/v1/dni/info/27427864"
Dim token As String = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI3IiwiZW1haWwiOiJhbmdlbGl0b2FsZXgyMDBAZ21haWwuY29tIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiY29uc3VsdG9yIn0.w8DwLqSuge7pO_CjTKliZGoMUyKYs5W-ft0Lz3sowpE"
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
request.Headers.Add("Authorization", token)
Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
Dim streamReader As New IO.StreamReader(response.GetResponseStream())
Dim responseData As String = streamReader.ReadToEnd()
Console.WriteLine(responseData)
streamReader.Close()
response.Close()
Console.ReadLine()
End Sub
End Module
EnvΓa un mensaje al WhatsApp indicando el lenguaje de programaciΓ³n y recibiras el codigo inmediato. wa.link/my8cvg
Γltima actualizaciΓ³n