Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiagofrancafernandes/dc269ff00e14e928d97998b627499876 to your computer and use it in GitHub Desktop.
Save tiagofrancafernandes/dc269ff00e14e928d97998b627499876 to your computer and use it in GitHub Desktop.
Assets, API, CURL, JS Fetch, etc
#curl POST com dados via JSON com autenticação básica
curl -X POST -u teste1:123 \
-H "Content-Type: application/json" \
-d '{"username":"abc","password":"abc"}' \
http://localhost:5678/webhook-test/create_account-start
##################################################
## Image placeholders
## Fotos de usuarios fake
# https://randomuser.me/api/portraits/men/97.jpg
# https://randomuser.me/api/portraits/women/97.jpg
## Imagens randomicas
# https://picsum.photos/
# https://picsum.photos/id/870/200/300
## Cortar imagem muito grande/pesada (deixar leve)
# imagecdn.app:
# https://imagecdn.app/v2/image/[IMAGE_URL_ENCODED]?width=SIZE
# Original: https://images6.alphacoders.com/526/526622.jpg
# https://imagecdn.app/v2/image/https%3A%2F%2Fimages6.alphacoders.com%2F526%2F526622.jpg?width=1024
# i0.wp
# https://i0.wp.com/www.php.net/images/meta-image.png?fit=256%2C256&ssl=1
##################################################
#API URLS
APIs públicas
./notas/devapi_urls
./notas/devapi_estudos
#----------------------------------------------------
https://gist.github.com/tiagofrancafernandes/dc269ff00e14e928d97998b627499876#file-curl-post-com-autenticacao-basica-sh
#curl POST com dados via JSON com autenticação básica
curl -X POST -u teste1:123 \
-H "Content-Type: application/json" \
-d '{"username":"abc","password":"abc"}' \
http://localhost:5678/webhook-test/create_account-start
#----------------------------------------------------
#----------------------------------------------------
#Post com wget
wget --no-check-certificate --quiet \
--method POST \
--timeout=0 \
--max-redirect=0 \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'app_token: Zq5baiPoqzjh' \
--header 'access_token: tf8nfifh4l6a' \
--body-data 'idplano=2&ST_NOME_SAC=Kaique' \
-qO - 'https://endpointaqui.com'
#----------------------------------------------------
#Post com php curl
https://stackoverflow.com/a/53909739/11716408
$url = 'http://url_post.com';
$data = ['algo' => valor];
$postdata = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
curl_close($ch);
$response = print_r ($result, true);
SimpleLog::logThis($response, 'exit');
#----------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment