Initial import
This commit is contained in:
130
one-api/application/controllers/tgram/Xonev2.php
Normal file
130
one-api/application/controllers/tgram/Xonev2.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
class Xonev2 extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
//-315860436
|
||||
//
|
||||
public function sasone() {
|
||||
$prm = $this->sys_input;
|
||||
$text = $prm["text"];
|
||||
$url = "https://api.telegram.org/bot858743704:AAGplPB1cwWmzAu37VMwiTFifWFCsJKIH10/sendMessage";
|
||||
$data = array (
|
||||
"chat_id" => "-315860436" ,
|
||||
"text" => $text,
|
||||
"parse_mode" => "MarkdownV2"
|
||||
);
|
||||
$j_data = json_encode($data);
|
||||
$this->post($url,$j_data);
|
||||
}
|
||||
public function send() {
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
$text = $prm["text"];
|
||||
$url = "https://api.telegram.org/bot858743704:AAGplPB1cwWmzAu37VMwiTFifWFCsJKIH10/sendMessage";
|
||||
$data = array (
|
||||
"chat_id" => $id ,
|
||||
"parse_mode" => "MarkdownV2",
|
||||
"text" => $text
|
||||
);
|
||||
$j_data = json_encode($data);
|
||||
$this->post($url,$j_data);
|
||||
}
|
||||
|
||||
|
||||
public function senddoc() {
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
$text = $prm["text"];
|
||||
$o_files= $prm["files"];
|
||||
$thumbs = $prm["thumbs"];
|
||||
$names= $prm["names"];
|
||||
$url = "https://api.telegram.org/bot858743704:AAGplPB1cwWmzAu37VMwiTFifWFCsJKIH10/sendDocument";
|
||||
$fields = array( "chat_id" => $id , "caption" => $text , "parse_mode" => "MarkdownV2");
|
||||
foreach($o_files as $idx => $file) {
|
||||
$files = array();
|
||||
$files[] = array(
|
||||
"name" => "document",
|
||||
"fname" => $names[$idx],
|
||||
"content" => file_get_contents($file)
|
||||
);
|
||||
$thumb = $thumbs[$idx];
|
||||
$files[] = array(
|
||||
"name" => "thumb",
|
||||
"fname" => "thumb.jpg",
|
||||
"content" => file_get_contents($thumb)
|
||||
);
|
||||
|
||||
$boundary ="-myboundary-xferv2-" . uniqid();
|
||||
$delimiter = '-------------' . $boundary;
|
||||
$message = $this->build_data_files($boundary,$fields,$files);
|
||||
//echo "$message";
|
||||
$result = $this->post_mf($url,$message,$delimiter);
|
||||
echo "Result : " . $result;
|
||||
}
|
||||
}
|
||||
function post_mf($url,$data,$delimiter) {
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => 1,
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POST => 1,
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
"Content-Type: multipart/form-data; boundary=" . $delimiter,
|
||||
"Content-Length: " . strlen($data)
|
||||
),
|
||||
));
|
||||
$result_a = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
$result = $result_a;
|
||||
if ($err) {
|
||||
$result = $result_a . "\nERR : " . print_r($err,true) . "\n" ;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function build_data_files($boundary, $fields, $files){
|
||||
$data = '';
|
||||
$eol = "\r\n";
|
||||
$delimiter = '-------------' . $boundary;
|
||||
foreach ($fields as $name => $content) {
|
||||
$data .= "--" . $delimiter . $eol
|
||||
. 'Content-Disposition: form-data; name="' . $name . "\"".$eol.$eol
|
||||
. $content . $eol;
|
||||
}
|
||||
foreach($files as $file) {
|
||||
$data .= "--" . $delimiter . $eol
|
||||
. 'Content-Disposition: form-data; name="' . $file["name"] . '"; filename="' . $file["fname"] . '"' . $eol
|
||||
//. 'Content-Type: image/png'.$eol
|
||||
. 'Content-Transfer-Encoding: binary'.$eol
|
||||
;
|
||||
|
||||
$data .= $eol;
|
||||
$data .= $file["content"] . $eol;
|
||||
$data .= "--" . $delimiter . "--".$eol;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
echo $result;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user