package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type User struct {
Id int `json:"id"`
Name string `json:"name"`
}
func main() {
url := "https://jsonplaceholder.typicode.com/users/1"
resp, _ := http.Get(url)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
var user User
json.Unmarshal(body, &user)
fmt.Println(user)
}
func main() {
fmt.Println("start")
cuit := "20-25851149-4"
apiURL := "https://api.afip.gob.ar/sr-padron/v2/persona/" + cuit
req, err := http.NewRequest("GET", apiURL, nil)
if err != nil {
panic(err.Error())
}
client := &http.Client{
Timeout: time.Second * 10,
}
req.SetBasicAuth("fakeuser", "fakepassword")
req.Header.Add("padron-usuario", "fakeuser")
req.Header.Add("padron-password", "fakepassword")
req.Header.Add("padron-token", "fakeuser")
resp, err := client.Do(req)
fmt.Println(resp)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
func Login(username string, password string) (User, error)
[HttpPost]
[Route("Login")]
public IHttpActionResult Login(Login login)
{
try
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SINTIA"].ConnectionString))
{
var query = "select * from [dbo].[User] where [UserName] = @username and [Password] = @password";
var cmd = new SqlCommand(query, conn);
cmd.Parameters.AddWithValue("username", login.UserName);
cmd.Parameters.AddWithValue("password", login.Password);
conn.Open();
var reader = cmd.ExecuteReader();
if (reader.HasRows)
{
reader.Read();
var accesstoken = Guid.NewGuid();
var query2 = "update [dbo].[User] set [AccessToken] = @accesstoken, [LastLogin] = getdate() where [UserName] = @username and [Password] = @password";
var cmd2 =
func login(url string, username string, password string) map[string]interface{} {
values := map[string]string{"Usuario": username, "Clave": password}
jsonValue, _ := json.Marshal(values)
response, err := http.Post(url, "application/json", bytes.NewBuffer(jsonValue))
if err != nil {
panic(err)
}
defer response.Body.Close()
bodyBytes, err := ioutil.ReadAll(response.Body)
if err != nil {
panic(err)
}
bodyString := string(bodyBytes)
fmt.Println(bodyString)
var result map[string]interface{}
json.Unmarshal(bodyBytes, &result)
return result
}
func login(username, password string) (Token, error) {
res, err := http.Post("https://apiadv.sintia.com.ar/api/Login",
"application/json",
strings.NewReader(fmt.Sprintf(`{"username": "%s", "password": "%s"}`, username, password)),
)
if err != nil {
return "", err
}
defer res.Body.Close()
if res.StatusCode != 200 {
return "", errors.New("invalid username/password")
}
var t Token
dec := json.NewDecoder(res.Body)
if err := dec.Decode(&t); err != nil {
return "", err
}
return t, nil
}
func main() {
client := &http.Client{}
req, err := http.NewRequest("GET", "https://test.test.com", nil)
req.Header.Set("Authorization", "Bearer " + "asdasdasdasd")
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
func RatificacionLogin() {
url := "https://apiadv.sintia.com.ar/Ratificacion/Login"
payload := strings.NewReader("{\n\t\"Username\":\"XXXXXX\",\n\t\"Password\":\"XXXXXXX\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
private void btnClasificar_Click(object sender, EventArgs e)
{
ClasificarContenido(txtRuta.Text);
}
class ClassifyImages
{
private string _imagesPath;
private string _imagesClassPath;
private string _imagesClassPath;
private string _imagesClassPath;
private string _imagesClassPath;
private string _imagesClassPath;
private string _imagesClassPath;
public ClassifyImages(string imagesPath)
{
_imagePath = imagesPath;
}
public void ClassifyContent()
{
string[] fileEntries = Directory.GetFiles(_imagesPath);
foreach (string fileName in fileEntries)
{
string[] parts = fileName.Split('\\');
string[] nameParts = parts[1].Split('.');
string tag = nameParts[0];
string filePath = $"{_imagesPath}{parts[1]}";
switch (tag)
{
case "M":
processFile("M", filePath);
break;
case "A":
processFile("A", filePath);
break;
case "N":
func getCuit(cuit string) *Cuit{
resp, err := http.Get("http://www.afip.gob.ar/datos/cuit.dat")
if err != nil {
log.Fatal(err)
}
// ...
}
package main
import "net/http"
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
func handler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Gorilla!\n"))
}
func Login(username, password string) {
url := "https://apiadv.sintia.com.ar/Ratificacion/Login"
var jsonStr = []byte(`{"Username":"` + username + `","Password":"` + password + `"}`)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("response Status:", resp.Status)
fmt.Println("response Headers:", resp.Header)
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println("response Body:", string(body))
}
public class LoginPost
{
public string User { get; set; }
public string Password { get; set; }
}
[HttpPost]
public async Task<IActionResult> Login()
{
var body = await Request.Body.ReadAsStringAsync();
var data = JsonConvert.DeserializeObject<LoginPost>(body);
var token = new TokenJWT();
if (data.User == "admin" && data.Password == "admin")
{
string jwt = token.GenerateToken(data.User);
return Ok(jwt);
}
return Unauthorized();
}