Skip to content

Instantly share code, notes, and snippets.

@dzhuryn
Created January 15, 2020 12:27
Show Gist options
  • Save dzhuryn/a8f8bafcca055e739f32924c7e9bf369 to your computer and use it in GitHub Desktop.
Save dzhuryn/a8f8bafcca055e739f32924c7e9bf369 to your computer and use it in GitHub Desktop.
Curl примеры
$ch = curl_init('https://www.gorgany.com/');
//кастомные заголовки
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
//не возвращать ответ в браузер
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
//base auth базовая авторизация
curl_setopt($ch, CURLOPT_USERPWD, "$userName:$userPassword");
//ответ
$response = json_decode(curl_exec($ch),true);
//информация об ответе
$pageInfo = curl_getinfo($ch);
// завершение сеанса и освобождение ресурсов
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment