php get curl version

curl_version

(PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8)

curl_version — Gets cURL version information

Description

Returns information about the cURL version.

Parameters

This function has no parameters.

Return Values

Returns an associative array with the following elements:

KeyValue description
version_numbercURL 24 bit version number
versioncURL version number, as a string
ssl_version_numberOpenSSL 24 bit version number
ssl_versionOpenSSL version number, as a string
libz_versionzlib version number, as a string
hostInformation about the host where cURL was built
age
featuresA bitmask of the CURL_VERSION_XXX constants
protocolsAn array of protocols names supported by cURL

Changelog

VersionDescription
8.0.0The optional age parameter has been removed.
7.4.0The optional age parameter has been deprecated; if a value is passed, it is ignored.

Examples

Example #1 curl_version() example

// Get curl version array
$version = curl_version ();

Источник

curl_getinfo

(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)

curl_getinfo — Возвращает информацию об определённой операции

Описание

Возвращает информацию о последней операции.

Список параметров

Возвращаемые значения

Список изменений

Примеры

Пример #1 Пример использования curl_getinfo()

// Создаём дескриптор cURL
$ch = curl_init ( ‘http://www.example.com/’ );

Пример #2 Пример использования curl_getinfo() с параметром option

// Создаём дескриптор cURL
$ch = curl_init ( ‘http://www.example.com/’ );

Примечания

Информация, собранная этой функцией, будет сохранена при дальнейшем использовании дескриптора. Это означает, что если статистика не будет перезаписана самой функцией, будет возвращаться информация по предыдущему запросу.

User Contributed Notes 13 notes

Here are the response codes ready for pasting in an ini-style file. Can be used to provide more descriptive message, corresponding to ‘http_code’ index of the arrray returned by curl_getinfo().
These are taken from the W3 consortium HTTP/1.1: Status Code Definitions, found at
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

[Informational 1xx]
100=»Continue»
101=»Switching Protocols»

[Successful 2xx]
200=»OK»
201=»Created»
202=»Accepted»
203=»Non-Authoritative Information»
204=»No Content»
205=»Reset Content»
206=»Partial Content»

[Redirection 3xx]
300=»Multiple Choices»
301=»Moved Permanently»
302=»Found»
303=»See Other»
304=»Not Modified»
305=»Use Proxy»
306=»(Unused)»
307=»Temporary Redirect»

[Client Error 4xx]
400=»Bad Request»
401=»Unauthorized»
402=»Payment Required»
403=»Forbidden»
404=»Not Found»
405=»Method Not Allowed»
406=»Not Acceptable»
407=»Proxy Authentication Required»
408=»Request Timeout»
409=»Conflict»
410=»Gone»
411=»Length Required»
412=»Precondition Failed»
413=»Request Entity Too Large»
414=»Request-URI Too Long»
415=»Unsupported Media Type»
416=»Requested Range Not Satisfiable»
417=»Expectation Failed»

[Server Error 5xx]
500=»Internal Server Error»
501=»Not Implemented»
502=»Bad Gateway»
503=»Service Unavailable»
504=»Gateway Timeout»
505=»HTTP Version Not Supported»

Источник

Клиентская библиотека работы с URL

User Contributed Notes 27 notes

I wrote the following to see if a submitted URL has a valid http response code and also if it responds quickly.

Use the code like this:

Hey I modified script for php 5. Also I add support server auth. and fixed some little bugs on the script.

[EDIT BY danbrown AT php DOT net: Original was written by (unlcuky13 AT gmail DOT com) on 19-APR-09. The following note was included:
Below is the my way of using through PHP 5 objecte oriented encapsulation to make thing easier.]

I needed to use cURL in a php script to download data using not only SSL for the server authentication but also for client authentication.
On a default install of Fedora, setting up the proper cURL parameters, I would get an error:

$ php curl.php
Peer certificate cannot be authenticated with known CA certificates

The data on http://curl.haxx.se/docs/sslcerts.html was most useful. Indeed, toward to bottom it tells you to add a missing link inside /etc/pki/nssdb to use the ca-bundle.crt file. You do it so:

Now you can do client authentication, provided you have your certificate handy with:

In this example: http://php.net/manual/en/book.curl.php#102885 by «frank at interactinet dot com»

There’s a small bug in

?>

The code will immediately leave the function at the `return`, and pcntl_wait() will NEVER be executed, under any circumstances.

I can’t see any other issues with this function however.

Sharing is caring, handles included.

$user_agent = ‘Mozilla HotFox 1.0’ ;

CURL failed with PHP5.3 and Apache2.2.X on my Windows 7 machine.

It turns out that it’s not enough to copy the two dll’s mentioned (libeay32 and sslea32) from the php folder into your system32 folder. You HAVE TO UNBLOCK THESE TWO FILES.

Right click the file, select unblock, for each one. Then restart Apache.

Another very handy security feature added into Windows.

Here you have a function that I use to get the content of a URL using cURL:

You can use this class for fast entry

[EDIT BY danbrown AT php DOT net: Includes a bugfix provided by (manuel AT rankone DOT ch) on 24-NOV-09 to properly reference cURL initialization.]

Источник

Php get curl version

PHP поддерживает libcurl, библиотеку, созданную Daniel»ом Stenberg»ом, которая даёт возможность соединяться с серверами различных типов и по разным протоколам.
libcurl в настоящее время поддерживает протоколы http, https, ftp, gopher, telnet, dict, file и ldap.
libcurl также поддерживает сертификаты HTTPS, HTTP POST, HTTP PUT, загрузку по FTP (это можно сделать также РНР-расширением ftp), загрузку на основе форм HTTP, прокси, куки и аутентификацию user+password.

Эти функции были введены в PHP 4.0.2.

curl_init

Описание

resource curl_init([string url])

Функция curl_init() инициализирует новую сессию и возвратит CURL-дескриптор для использования в функциях curl_setopt(), curl_exec() и curl_close(). Если необязательный параметр url предоставлен, то опция CURLOPT_URL получит значение этого параметра. Вы можете вручную устанавливать его с помощью функции curl_setopt().

curl_setopt

Описание

bool curl_setopt (resource ch, string option, mixed value)

Функция curl_setopt() устанавливает опции для CURL-сессии, идентифицируемой параметром ch. Параметр option является опцией, которую вы хотите установить, а value это значение опции option.

Параметр value должен быть long для следующих опций (специфицированных параметром option):

Параметр value должен быть строкой для следующих значений параметра option:

Следующие опции ожидают дескриптора файла, который получается с помощью функции fopen():

Параметр value должен быть функцией следующего вида long write_callback (resource ch, string data) для следующих значений параметра option:

Параметр value должен быть функцией следующего вида string read_callback (resource ch, resource fd, long length)<> для следующих значений параметра option:

Источник

Что JavaScript-разработчику следует знать о Curl

Доброго времени суток, друзья!

Представляю Вашему вниманию перевод статьи «What JavaScript Developers Should Know About Curl» автора Valery Karpov.

Curl — это популярный инструмент командной строки, часто используемый для отправки HTTP-запросов. Curl поддерживает большое количество протоколов, однако как Node.js-разработчик вы, скорее всего, будете использовать его для отпраки http-запросов к RESTful API.

Документация curl представляет собой перечень из 383 флагов командной строки, поэтому в ней очень трудно найти то, что ищешь. В этой статье я хочу поделиться с вами некоторыми часто используемыми мной шаблонами. Для примеров будет использоваться сервис httpbin.org.

Отправка http-запроса

Загрузка файлов

Wget — самый распространенный инструмент для загрузки файлов посредством командной строки. Он входит в комплект большинства диструбутивов Linux. Однако в OSX его нет.

php get curl version. Смотреть фото php get curl version. Смотреть картинку php get curl version. Картинка про php get curl version. Фото php get curl version

Для загрузки этого изобюражения необходимо выполнить следующее:

Отправка авторизованного запроса

Вот что происходит при отправке неправильного имени пользователя или пароля:

Отправка POST-запроса, содержащего JSON

Отправка PUT-запроса, содержащего JSON-файл

Заключение

Резюмируя, вот опции curl, которые я нахожу самыми полезными:

Благодарю за потраченное время. Надеюсь, оно было потрачено не зря.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *