Skip to content

VenityNetwork/CurlLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CurlLib

An asynchronous Curl library for PocketMine-MP

Don't do HTTP Request in an async task! It will block other async tasks like world population, packets compression and others

Usage

  • Initialization
$threads = 1; // Increase this if you have a lot of http requests
/** @var CurlLib $curl */
$curl = CurlLib::init($plugin, $threads);
  • GET request
// example to get IP information
$url = "http://ip-api.com/json/24.48.0.1";
$headers = [];
$curlOpts = [];
/** @var CurlLib $curl */
$curl->get($url, $headers, $curlOpts, function(CurlResponse $response) {
    echo $response->getStatusCode() . "\n";
    echo $response->getBody() . "\n";
    echo $response->getHeaders() . "\n";
});
  • POST request
// example to send message via discord webhook
$url = "https://discord.com/api/webhooks/12345/XXXXX";
$postField = json_encode(["content" => "Hello World"]);
$headers = [
    "Content-Type: application/json"
];
$curlOpts = [];
/** @var CurlLib $curl */
$curl->post($url, $postField, $headers, $curlOpts, function(CurlResponse $response) {
    echo $response->getStatusCode() . "\n";
    echo $response->getBody() . "\n";
    echo $response->getHeaders() . "\n";
});

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages