Свести IEnumerable < IEnumerable < > & gt ;; понимание дженериков

Этот ответ взял меня навсегда, чтобы найти. Я обнаружил, что все, что вам нужно сделать, это конкатенация URL-адреса («?» После имени файла и расширения) с помощью строки запроса с кодировкой URL. Это даже не похоже на то, что вы должны установить параметры POST cURL. См. Поддельный пример ниже:

//create URL
$exampleURL = 'http://www.example.com/example.php?';

// create curl resource
$ch = curl_init(); 

// build URL-encoded query string
$data = http_build_query(
    array('first' => 'John', 'last' => 'Smith', '&'); // set url
curl_setopt($ch, CURLOPT_URL, $exampleURL . $data); 

// return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

// $output contains the output string
$output = curl_exec($ch); 

// close curl resource to free up system resources <br/>
curl_close($ch);

Вы также можете использовать file_get_contents():

// read entire webpage file into a string
$output = file_get_contents($exampleURL . $data);
34
задан Community 23 May 2017 в 12:26
поделиться