ロリCURL
このコミットが含まれているのは:
コミット
1566079e57
|
@ -3,8 +3,14 @@
|
|||
define('APP_NAME', 'LoliPHP');
|
||||
|
||||
// データベース
|
||||
define('DB_CONN', 'mysql'); // mysql|pgsql
|
||||
define('DB_HOST', 'localhost');
|
||||
define('DB_PORT', 3306);
|
||||
define('DB_USER', '');
|
||||
define('DB_PASS', '');
|
||||
define('DB_NAME', '');
|
||||
|
||||
// CURL
|
||||
define('API_URI', '');
|
||||
define('API_AUTH', null);
|
||||
?>
|
||||
|
|
20
helper.php
20
helper.php
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
require_once('./helper/php8compat.php'); // PHP8を実行していない場合・If not running PHP8
|
||||
require_once('./helper/debug.php'); // デバッガー・Debugger
|
||||
require_once('./helper/db.php'); // データベースエンジン・Database engine
|
||||
require_once('./helper/request.php'); // リクエスト・Request
|
||||
require_once('./helper/upload.php'); // ファイルアップロード・File upload
|
||||
require_once('./helper/curl.php'); // CURL
|
||||
require_once('./helper/cookie.php'); // クッキー・Cookie
|
||||
require_once('./helper/mail.php'); // メール・Mail
|
||||
require_once('./helper/session.php'); // セッション・Session
|
||||
require_once('./helper/hash.php'); // ハッシュ・Hash
|
||||
require_once('helper/php8compat.php'); // PHP8を実行していない場合・If not running PHP8
|
||||
require_once('helper/debug.php'); // デバッガー・Debugger
|
||||
require_once('helper/db.php'); // データベースエンジン・Database engine
|
||||
require_once('helper/request.php'); // リクエスト・Request
|
||||
require_once('helper/upload.php'); // ファイルアップロード・File upload
|
||||
require_once('helper/curl.php'); // CURL
|
||||
require_once('helper/cookie.php'); // クッキー・Cookie
|
||||
require_once('helper/mail.php'); // メール・Mail
|
||||
require_once('helper/session.php'); // セッション・Session
|
||||
require_once('helper/hash.php'); // ハッシュ・Hash
|
||||
?>
|
||||
|
|
|
@ -1,3 +1,37 @@
|
|||
<?php
|
||||
function lolicurl () {}
|
||||
require_once('../config.php');
|
||||
|
||||
function lolicurl ($url, $param='', $method='get', $contenttype='json') {
|
||||
set_time_limit(0);
|
||||
$header = ['Content-Type: application/'.$contenttype, 'Host: '.str_replace('https://', '', API_URI)];
|
||||
|
||||
if (!is_null(API_AUTH)) {
|
||||
$header[] = 'Authorization: Bearer '.API_AUTH;
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, API_URI.$url);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
||||
if ($method == 'post') {
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
if ($param != '') curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
$get = curl_exec($ch);
|
||||
$err = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if (!$get) {
|
||||
return $err;
|
||||
}
|
||||
|
||||
$get = json_decode($get);
|
||||
|
||||
if (isset($get->status) && $get->status == 404) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $get;
|
||||
}
|
||||
?>
|
||||
|
|
読み込み中…
新しいイシューから参照