0
Good afternoon guys, I need a little help.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://pubproxy.com/api/proxy?api=...');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
$json = json_decode($data);
$proxy = $json->data->ipPort;
echo $proxy;
I am unable to extract ipport from the json page. Answer from the site:
{"data":[{"ipPort":"83.169.202.2:3128","ip":"83.169.202.2","port":"3128","country":"RU","last_checked":"2018-07-22 09:05:20","proxy_level":"anonymous","type":"http","speed":"15","support":{"https":1,"get":1,"post":1,"cookies":1,"referer":1,"user_agent":1,"google":0}}],"count":1}
I’ve tried these ways:
$proxy = $json->data->ipPort;
$proxy = $json->ipPort;
$json->data["0"]->ipPort;
?– Costamilam
@Guilhermecostamilam, wouldn’t it
$json->data[0]->ipPort
, without the quotation marks?– Wees Smith
@Weessmith do not remember, so I put only in comment, but think that both work
– Costamilam
remains to be seen if it worked kk
– Wees Smith
has already got the answer?
– Thiago Magalhães