PHP code example of starrysea / curl
1. Go to this page and download the library: Download starrysea/curl 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/ */
starrysea / curl example snippets
'providers' => [
// ...
Starrysea\Curl\CurlServiceProvider::class,
];
'aliases' => [
// ...
'Curl' => Starrysea\Curl\Curl::class,
];
$app->register(Starrysea\Curl\CurlServiceProvider::class); // 注册 Curl 服务提供者
class_alias(Starrysea\Curl\Curl::class, 'Curl'); // 添加 Curl 门面
use Starrysea\Curl\Curl;
class CurlGatherTest
{
public static function get_curl()
{
return Curl::get_curl('https://github.com/caixingyue/laravel-starrysea-curl'); // get request
// return Curl::get_curl('https://github.com/caixingyue/laravel-starrysea-curl', [
// 'title' => '你好, Laravel'
// ]); // post request
// return Curl::get_curl('https://github.com/caixingyue/laravel-starrysea-curl', [
// 'title' => '你好, Laravel'
// ],[
// 'headers' => '星月来啦'
// ]); // post and header request
}
public static function first()
{
return Curl::first()->get('https://github.com/caixingyue/laravel-starrysea-curl', [
'title' => '你好, Laravel'
])->request(); // get request
// return Curl::first()->post('https://github.com/caixingyue/laravel-starrysea-curl', [
// 'title' => '你好, Laravel'
// ])->request(); // post request
// return Curl::first()->get('https://github.com/caixingyue/laravel-starrysea-curl')->headers([
// 'title' => '你好, Laravel'
// ])->request(); // get and header request
}
}