Skip to content

nichin79/curl-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

curl

Contains two classes:

  • Curl
  • BasicCurl

BasicCurl extends Curl and will automatically use the curlopt's

  • ssl_verifypeer
  • returntransfer. In addition it will also execute the curl automatically.

If curlopt_returntransfer is set, the response can be retrieved with $curl->getResponse().

use Nichin79\Curl\BasicCurl; OR use Nichin79\Curl\Curl;

Setting the params/options for curl can be done in two ways:

Option 1

$data = [
  'url' => 'https://reqbin.com/echo',
  'method' => 'GET', // Method will automatically be set to GET if not specified
  'headers' => [],
  'options' => [
  'SSL_VERIFYPEER' => false
  ]
];

Option 2

$data = [
  'curlopt_url' => 'https://reqbin.com/echo',
  'curlopt_ssl_verifypeer' => false,
];

Usage

$curl = new Curl($data);

// execute the initiated curl and return the response
$curl->exec();

echo "\r\n";
echo "http status code: " . $curl->httpcode;

Setting url, method, headers and data are optional and can be set inside the options array as well.

About

Basic php script for curl

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages