Json no viene a variable.

  • Autor Autor Prospero
  • Fecha de inicio Fecha de inicio
Prospero

Prospero

Eta
Verificación en dos pasos activada
Hola amigos, estoy trayendo un screenshot de un sitio pero en modo json no me lo toma como variable. que estoy haciendo mal.

Insertar CODE, HTML o PHP:
<?php

$url = "https://geekflare.com/api/geekflare-api/screenshot";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "authority: geekflare.com",
   "accept: application/json, text/plain, */*",
   "accept-language: es-ES,es-US;q=0.9,es-AR;q=0.8,es;q=0.7,en-US;q=0.6,en;q=0.5",
   "content-type: application/json",
   "cookie: _ga=GA1.2.1489152377.1649766574; _gid=GA1.2.1915494195.1649766574; aawp-geotargeting=AR; __cf_bm=n49YrAbUKSvH2nL3pbLcar1tzFLt3zWnODIG3qNyN64-1649769787-0-AWoSbROhZ+8XjIcpd7to/QXiyuMHbMVDJVURtipOALnHQQgrML07V5BTYhmbxlUVLVP2pafABtzYa/+UPymGdaiQ4C8XsVmnE2R3BKBfYcEroEFzCZB4Txnmd8n/m/+3mw==; _gat_gtag_UA_58443135_1=1",
   "origin: https://geekflare.com",
   "referer: https://geekflare.com/api",
   'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"',
   "sec-ch-ua-mobile: ?0",
   'sec-ch-ua-platform: "Windows"',
   "sec-fetch-dest: empty",
   "sec-fetch-mode: cors",
   "sec-fetch-site: same-origin",
   "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$data = '{"url":"https://www.google.com/"}';

curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);


$con = utf8_encode($resp);
$datos = json_decode($con, true);
$screen = $datos['data']['0']['screenshot'];

echo $screen;

?>

algo que me recomienden leer? es el segundo codigo json que no puedo traer.

gracias!! los leo!!
 
¿Te sirvió? Únete a la conversación

Con tu cuenta gratis puedes responder, escribirle al autor por mensaje privado y comprar con Saldo retenido: el pago se libera cuando recibes lo acordado.

Toma 30 segundos · vuelves a este tema al terminar
Pega
PHP:
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

Arriba de
PHP:
$resp = curl_exec($curl);
 
Hola amigos, estoy trayendo un screenshot de un sitio pero en modo json no me lo toma como variable. que estoy haciendo mal.

Insertar CODE, HTML o PHP:
<?php

$url = "https://geekflare.com/api/geekflare-api/screenshot";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "authority: geekflare.com",
   "accept: application/json, text/plain, */*",
   "accept-language: es-ES,es-US;q=0.9,es-AR;q=0.8,es;q=0.7,en-US;q=0.6,en;q=0.5",
   "content-type: application/json",
   "cookie: _ga=GA1.2.1489152377.1649766574; _gid=GA1.2.1915494195.1649766574; aawp-geotargeting=AR; __cf_bm=n49YrAbUKSvH2nL3pbLcar1tzFLt3zWnODIG3qNyN64-1649769787-0-AWoSbROhZ+8XjIcpd7to/QXiyuMHbMVDJVURtipOALnHQQgrML07V5BTYhmbxlUVLVP2pafABtzYa/+UPymGdaiQ4C8XsVmnE2R3BKBfYcEroEFzCZB4Txnmd8n/m/+3mw==; _gat_gtag_UA_58443135_1=1",
   "origin: https://geekflare.com",
   "referer: https://geekflare.com/api",
   'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"',
   "sec-ch-ua-mobile: ?0",
   'sec-ch-ua-platform: "Windows"',
   "sec-fetch-dest: empty",
   "sec-fetch-mode: cors",
   "sec-fetch-site: same-origin",
   "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$data = '{"url":"https://www.google.com/"}';

curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);


$con = utf8_encode($resp);
$datos = json_decode($con, true);
$screen = $datos['data']['0']['screenshot'];

echo $screen;

?>

algo que me recomienden leer? es el segundo codigo json que no puedo traer.

gracias!! los leo!!
Asi me funciona!

PHP:
<?php

$url = 'https://geekflare.com/api/geekflare-api/screenshot';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "authority: geekflare.com",
   "content-type: application/json",
   "cookie: _ga=GA1.2.1489152377.1649766574; _gid=GA1.2.1915494195.1649766574; aawp-geotargeting=AR; __cf_bm=n49YrAbUKSvH2nL3pbLcar1tzFLt3zWnODIG3qNyN64-1649769787-0-AWoSbROhZ+8XjIcpd7to/QXiyuMHbMVDJVURtipOALnHQQgrML07V5BTYhmbxlUVLVP2pafABtzYa/+UPymGdaiQ4C8XsVmnE2R3BKBfYcEroEFzCZB4Txnmd8n/m/+3mw==; _gat_gtag_UA_58443135_1=1",
   "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$data = '{"url":"https://www.google.com/"}';
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);

$json = json_decode($resp, true);
echo $json['data'][0]['screenshot'];

?>
 
Asi me funciona!

PHP:
<?php

$url = 'https://geekflare.com/api/geekflare-api/screenshot';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "authority: geekflare.com",
   "content-type: application/json",
   "cookie: _ga=GA1.2.1489152377.1649766574; _gid=GA1.2.1915494195.1649766574; aawp-geotargeting=AR; __cf_bm=n49YrAbUKSvH2nL3pbLcar1tzFLt3zWnODIG3qNyN64-1649769787-0-AWoSbROhZ+8XjIcpd7to/QXiyuMHbMVDJVURtipOALnHQQgrML07V5BTYhmbxlUVLVP2pafABtzYa/+UPymGdaiQ4C8XsVmnE2R3BKBfYcEroEFzCZB4Txnmd8n/m/+3mw==; _gat_gtag_UA_58443135_1=1",
   "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$data = '{"url":"https://www.google.com/"}';
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);

$json = json_decode($resp, true);
echo $json['data'][0]['screenshot'];

?>
Ya lo tenia pero comentado
 
Hola amigos, estoy trayendo un screenshot de un sitio pero en modo json no me lo toma como variable. que estoy haciendo mal.

Insertar CODE, HTML o PHP:
<?php

$url = "https://geekflare.com/api/geekflare-api/screenshot";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "authority: geekflare.com",
   "accept: application/json, text/plain, */*",
   "accept-language: es-ES,es-US;q=0.9,es-AR;q=0.8,es;q=0.7,en-US;q=0.6,en;q=0.5",
   "content-type: application/json",
   "cookie: _ga=GA1.2.1489152377.1649766574; _gid=GA1.2.1915494195.1649766574; aawp-geotargeting=AR; __cf_bm=n49YrAbUKSvH2nL3pbLcar1tzFLt3zWnODIG3qNyN64-1649769787-0-AWoSbROhZ+8XjIcpd7to/QXiyuMHbMVDJVURtipOALnHQQgrML07V5BTYhmbxlUVLVP2pafABtzYa/+UPymGdaiQ4C8XsVmnE2R3BKBfYcEroEFzCZB4Txnmd8n/m/+3mw==; _gat_gtag_UA_58443135_1=1",
   "origin: https://geekflare.com",
   "referer: https://geekflare.com/api",
   'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"',
   "sec-ch-ua-mobile: ?0",
   'sec-ch-ua-platform: "Windows"',
   "sec-fetch-dest: empty",
   "sec-fetch-mode: cors",
   "sec-fetch-site: same-origin",
   "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$data = '{"url":"https://www.google.com/"}';

curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);


$con = utf8_encode($resp);
$datos = json_decode($con, true);
$screen = $datos['data']['0']['screenshot'];

echo $screen;

?>

algo que me recomienden leer? es el segundo codigo json que no puedo traer.

gracias!! los leo!!
a mi me corre bien :v
 
Asi me funciona!

PHP:
<?php

$url = 'https://geekflare.com/api/geekflare-api/screenshot';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "authority: geekflare.com",
   "content-type: application/json",
   "cookie: _ga=GA1.2.1489152377.1649766574; _gid=GA1.2.1915494195.1649766574; aawp-geotargeting=AR; __cf_bm=n49YrAbUKSvH2nL3pbLcar1tzFLt3zWnODIG3qNyN64-1649769787-0-AWoSbROhZ+8XjIcpd7to/QXiyuMHbMVDJVURtipOALnHQQgrML07V5BTYhmbxlUVLVP2pafABtzYa/+UPymGdaiQ4C8XsVmnE2R3BKBfYcEroEFzCZB4Txnmd8n/m/+3mw==; _gat_gtag_UA_58443135_1=1",
   "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$data = '{"url":"https://www.google.com/"}';
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);

$json = json_decode($resp, true);
echo $json['data'][0]['screenshot'];

?>
sin duda funciona! gracias! jaja veo q se eliminaron muchas cosas que no va. parece. graciiias!
 
Atrás
Arriba