我想用Curl https:/www.instagram.comdurov?__a=1. 浏览器打开页面。Postman返回数据,但当我试图使用php curl - 我收到空白页。有谁知道如何解决这个问题?
我的代码。
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.instagram.com/durov/?__a=1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"postman-token: 406fa2df-4649-b3af-1fcb-806d9be8678f"
),
));
$data = curl_exec($curl);
$err = curl_error($curl);
为什么不直接用这个单行本呢?
file_get_contents('https://www.instagram.com/durov/?__a=1');
所以...
<?php
$json = file_get_contents('https://www.instagram.com/durov/?__a=1');
$array = json_decode($json, true);
var_dump($array); // Do anything you want with the data