Skip to content

Easy to use, general purpose CuRL wrapper πŸ“ƒπŸ’»πŸ’

Notifications You must be signed in to change notification settings

TheWebChimp/curly-php

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Easy to use, general purpose CuRL wrapper

Basic usage

You'll need to include cacher.inc.php from here before including curly.inc.php.

<?php
	// Just grab a new instance, the boolean parameter controls caching:
	$curly = Curly::newInstance(false)
		->setMethod('get')
		->setURL('http://api.icndb.com/jokes/random')
		->setParams([ 'limitTo' => 'nerdy' ])
		->execute();
	// Then just get the response, you may even specify the format ('plain' or 'json')
	$res = $curly->getResponse('json');
	// Then just get the response, you may even specify the format ('plain' or 'json')
	$res = $curly->getResponse('json');
	// And just use the returned data
	if ($res && $res->type == 'success') {
		# Error checking may vary, here the API sets a } `type` member
		echo $res->value->joke;
	} else {
		echo 'API error: ' . $curly->getError();
	}
?>

For HTTPS just grab a copy of cacert.pem from here and drop it on the same folder where the curly.inc.php file is located.

Licensing

This software is released under the MIT license.

About

Easy to use, general purpose CuRL wrapper πŸ“ƒπŸ’»πŸ’

Topics

Resources

Stars

Watchers

Forks

Languages

  • PHP 96.9%
  • HTML 3.1%