import requests
API_TOKEN = "[Ваш API ключ]"
API_ENDPOINT = "https://api.spamham.ru/v1/processImage"
if __name__ == "__main__":
data = {
"models": "nsfw",
"url": "http://www.lenna.org/full/len_full.jpg"
}
headers = {
"Authorization": f"Bearer: {API_TOKEN}"
}
r = requests.post(
API_ENDPOINT,
data=data,
headers=headers
)
print(r.json())
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
)
const API_TOKEN string = "[Ваш API ключ]"
const API_ENDPOINT string = "https://api.spamham.ru/v1/processImage"
func main() {
models := "nsfw"
url := "http://www.lenna.org/full/len_full.jpg"
data := []byte(fmt.Sprintf("models=%s&url=%s", models, url))
req, err := http.NewRequest("POST", API_ENDPOINT, bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer: %s", API_TOKEN))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
client := &http.Client{}
responce, err := client.Do(req)
if err != nil {
panic(err)
}
body, err := ioutil.ReadAll(responce.Body)
if err != nil {
panic(err)
}
defer responce.Body.Close()
if responce.StatusCode == http.StatusOK {
fmt.Println("Responce:", string(body))
} else {
fmt.Println("Error:", string(body))
}
}
<?php
define("API_TOKEN", "[Ваш API ключ]");
define("API_ENDPOINT", "https://api.spamham.ru/v1/processImage");
$fields = [
'models' => "nsfw",
'url' => "http://www.lenna.org/full/len_full.jpg"
];
$headers = array();
$headers[] = 'Authorization: Bearer: '.API_TOKEN;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, API_ENDPOINT);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
echo $result;
?>
curl --data "models=nsfw&url=http://www.lenna.org/full/len_full.jpg" \
--header "Authorization: Bearer: [Ваш API ключ]" \
--request POST "https://api.spamham.ru/v1/processImage"
{
"ok": true,
"results": [
{
"class": "nsfw",
"confidence": 1.0,
"transaction_id": "f7b30bd9-e7df-453f-806d-e470a183b9ef"
}
]
}