PHP code example of cdcchen / curl-client
1. Go to this page and download the library: Download cdcchen/curl-client library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cdcchen / curl-client example snippets
$request = new HttpRequest();
$request->setUrl('http://www.baidu.com')
$response = $request->send();
$response->setFormat(HttpRequest::FORMAT_JSON);
$response->getStatus()
$response->getContent();
$response->hasHeader($name);
$response->getHeader($name);
$response->getHeaders();
$response->getCookies();
$request->setConnectTimeout($value, $ms = false);
$request->setTimeout($value, $ms = false);
$request->setMethod('post');
$request->setData(array $data);
$request->setContent($content);
$request->addHeader($name, $value);
$request->addHeaders($headers);
$request->removeHeader($name);
$request->clearHeaders();
$request->addCookie($name, $value);
$request->addCookies($cookies);
$request->setCookieFile($file, $jar = null);
$reqeust->setSSL($peer = false, $host = 2, array $extraOptions = []);
$request->addFile($input_name, $file, $mime_type = null, $post_name = null);
$request->addFiles($input_name, array $files, $mime_type = null, $post_name = null);
$request->clearFiles();
$request->setFormat($value);
$request->addOption($name, $value);
$request->addOptions(array $options);
$request->removeOptions($options);
$request->clearOptions();
$request->resetOptions($setDefaultOptions = true);
$request->setReferrer($referrer = true);
$request->setBasicAuth($username, $password);
$request->setUserPassword($username, $password);
$request->setUserAgent($agent);
$request->setFollowLocation($value = true, $maxRedirects = 5);
$request->setVersion($version);
$request->setAcceptEncoding($value);