From b1e2ddc271ada84a5e7c254ec49abc84eadc9beb Mon Sep 17 00:00:00 2001 From: string1995 Date: Thu, 27 Dec 2018 04:57:38 +0800 Subject: [PATCH] curl, dogeCloud api --- config.example.php | 6 +++++- functions.php | 37 +++++++++++++++++++++++++++++++++++++ test/curl.php | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 test/curl.php diff --git a/config.example.php b/config.example.php index e8a5813..034d619 100644 --- a/config.example.php +++ b/config.example.php @@ -4,4 +4,8 @@ $g_db_serverName="Your database server IP or Name"; $g_db_usrName="Your database user name"; $g_db_psswd="Your password"; -$g_db_dbName="The main database you select"; \ No newline at end of file +$g_db_dbName="The main database you select"; + +//dogecloud API +$dc_AccessKey = "Your_AccessKey"; +$dc_SecretKey = "Your_SecretKey"; \ No newline at end of file diff --git a/functions.php b/functions.php index c09269c..9c5c616 100644 --- a/functions.php +++ b/functions.php @@ -505,3 +505,40 @@ newVideo('$id'); } + + +/****API******/ + + +//fnct for dogecloud API +function api__dogecloud($platform,$vcode,$ip,$AccessKey,$SecretKey){ + + $url="https://api.dogecloud.com/video/streams.json?platform=$platform&vcode=$vcode&ip=$ip"; + + $str="/video/streams.json?platform=pch5&vcode=7119902f856c85a0&ip=49.64.195.241"."\n"; + + $str = hash_hmac("sha1", $str, $SecretKey); + + $headerArray =array("Host:api.dogecloud.com","Authorization: TOKEN ".$AccessKey.":".$str); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch,CURLOPT_HTTPHEADER,$headerArray); + $output = curl_exec($ch); + if($errno = curl_errno($ch)) { + $error_message = curl_strerror($errno); + echo "cURL error ({$errno}):\n {$error_message}"; + } + + curl_close($ch); + + return $output; +} + + + + + + diff --git a/test/curl.php b/test/curl.php new file mode 100644 index 0000000..403f195 --- /dev/null +++ b/test/curl.php @@ -0,0 +1,37 @@ +