Skip to content

Commit 7e50455

Browse files
authoredMar 31, 2022
Add files via upload
1 parent 0e0fd40 commit 7e50455

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+21429
-0
lines changed
 

‎composer.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "cachesistemas/whatsapp",
3+
"description": "Classe API WhatsApp",
4+
"type": "project",
5+
"license": "MIT",
6+
"autoload": {
7+
"psr-4": {
8+
"API\\": "scr/"
9+
}
10+
},
11+
"authors": [{
12+
"name": "Raphael Serafim",
13+
"email": "raphaelvserafim@gmail.com"
14+
}],
15+
"require": {
16+
"pear/http_request2": "^2.5"
17+
}
18+
}

‎scr/Container.php

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
4+
5+
namespace API;
6+
7+
8+
class Container
9+
{
10+
11+
private $token;
12+
private $url;
13+
14+
public function __construct($dados)
15+
{
16+
17+
$this->vazio($dados["url"]);
18+
$this->vazio($dados["token"]);
19+
20+
$this->url = $dados["url"];
21+
$this->token = $dados["token"];
22+
}
23+
24+
25+
private function vazio($value)
26+
{
27+
if (empty($value)) {
28+
echo json_encode(array("status" => false, "mensagem" => "campo obrigatório vazio"));
29+
exit;
30+
}
31+
}
32+
33+
34+
public function criar($id, $memoria)
35+
{
36+
$id = preg_replace("/\D/", "", $id);
37+
$this->vazio($id);
38+
$this->vazio($memoria);
39+
40+
return file_get_contents($this->url . '/run/' . $this->token . '/' . $id . '/' . $memoria);
41+
}
42+
43+
public function lista()
44+
{
45+
$containes = file_get_contents($this->url . '/list/' . $this->token);
46+
$containes = explode("\n", $containes);
47+
$array = array();
48+
for ($i = 1; sizeof($containes) >= $i; $i++) {
49+
if (!empty($containes[$i])) {
50+
$c = explode(" ", $containes[$i]);
51+
array_push($array, array("codigo" => $c[0], "api" => preg_replace("/\D/", "", $c[sizeof($c) - 1])));
52+
}
53+
}
54+
55+
return json_encode($array);
56+
}
57+
58+
public function start($id)
59+
{
60+
$this->vazio($id);
61+
return file_get_contents($this->url . '/start/' . $this->token . '/' . $id);
62+
}
63+
64+
public function stop($id)
65+
{
66+
$this->vazio($id);
67+
return file_get_contents($this->url . '/stop/' . $this->token . '/' . $id);
68+
}
69+
70+
public function deletar($id)
71+
{
72+
$this->vazio($id);
73+
return file_get_contents($this->url . '/delete/' . $this->token . '/' . $id);
74+
}
75+
}

0 commit comments

Comments
 (0)