Created
January 15, 2020 12:27
-
-
Save dzhuryn/a8f8bafcca055e739f32924c7e9bf369 to your computer and use it in GitHub Desktop.
Curl примеры
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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