-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfree.class.php
More file actions
36 lines (31 loc) · 817 Bytes
/
free.class.php
File metadata and controls
36 lines (31 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* Class Free mobile SMS
* Allow you to send SMS to yourself
* user -> login free.fr
* key -> api key that you can get from free.fr
*/
class FREE
{
const API_URL = 'https://smsapi.free-mobile.fr/sendmsg?user=%s&pass=%s&msg=%s';
private $apiUser;
private $apiKey;
public function __construct($user,$key)
{
$this->apiUser = $user;
$this->apiKey = $key;
}
public function sendMessage($msg) {
$url = sprintf(self::API_URL, $this->apiUser,$this->apiKey, urlencode($msg));
$res = $this->curlRequestJson($url);
}
private function curlRequestJson($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
return json_decode($output, true);
}
}
?>