1 | <?php |
||
9 | class Orange |
||
10 | { |
||
11 | public $url = 'https://www.orange.pl'; // orange.pl URL |
||
12 | private $user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4'; |
||
13 | private $login_request_uri = '/zaloguj.phtml'; // login form request uri |
||
14 | private $login_post_query_string = '?_DARGS=/ocp/gear/infoportal/portlets/login/login-box.jsp'; // login form POST query string |
||
15 | private $send_request_uri = '/portal/map/map/message_box?mbox_edit=new&mbox_view=newsms'; // request uri of form for sending new messages |
||
16 | private $send_post_request_uri = '/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp'; // action target for POST request of the sending new messages form |
||
17 | private $messages_request_uri = '/portal/map/map/message_box?mbox_view=sentmessageslist'; // request uri of the sent messages list |
||
|
|||
18 | public $max_length = '640'; // max. length of one SMS message according to the sending new messages form |
||
19 | |||
20 | /** |
||
21 | * @var session |
||
22 | * @var html |
||
23 | * @var dynSess |
||
24 | * @var token |
||
25 | */ |
||
26 | private $session; |
||
27 | private $html; |
||
28 | private $dynSess; |
||
29 | private $token; |
||
30 | |||
31 | /** |
||
32 | * Instantiates the Requests handler with Session support. |
||
33 | */ |
||
34 | public function __construct() |
||
47 | |||
48 | /** |
||
49 | * Login at orange.pl |
||
50 | * |
||
51 | * You have to be register at orange.pl |
||
52 | * Head to: https://www.orange.pl/rejestracja.phtml |
||
53 | * |
||
54 | * @param string $login - login or the number assosciated with the service you use |
||
55 | * @param string $password - password (pol. "Hasło") |
||
56 | */ |
||
57 | public function login($login, $password) |
||
90 | |||
91 | /** |
||
92 | * Retrieves the token from the webform |
||
93 | * |
||
94 | * @param string $content - content to be searched through |
||
95 | * @return string - token |
||
96 | */ |
||
97 | private function token($content) |
||
103 | |||
104 | /** |
||
105 | * Send a SMS through the webform at $this->send_post_request_uri |
||
106 | * |
||
107 | * @param string $recipient - number of the recipient (9 digits without leading zero for national numbers e.g. 501234567; two leading zeros followed by prefix for international numbers e.g. 004912345678901; no spaces or special chars) |
||
108 | * @param string $text - content of the SMS |
||
109 | */ |
||
110 | // TODO: check number of recipient for validaty |
||
111 | public function send($recipient, $text) |
||
151 | |||
152 | /** |
||
153 | * Find element in HTML Dom |
||
154 | * |
||
155 | * @param string $content - content to be searched through |
||
156 | * @return object |
||
157 | */ |
||
158 | private function find($content, $selector, $nth = null) |
||
169 | |||
170 | /** |
||
171 | * Checks the remaining SMS left this month from the response body |
||
172 | * |
||
173 | * @param string $content - content to be searched through |
||
174 | * @return boolean/int/string - free SMS this month; false if no content; int if int value present; other cases string |
||
175 | */ |
||
176 | private function free($content) |
||
195 | |||
196 | /** |
||
197 | * Checks the remaining SMS left this month making a GET request |
||
198 | * |
||
199 | * @return int - free SMS this month |
||
200 | */ |
||
201 | public function getFree() |
||
209 | |||
210 | /** |
||
211 | * Check whether errors have been returned |
||
212 | * |
||
213 | * @param string $content - response body of a request |
||
214 | * @return boolean - false if an element described by the selector exists |
||
215 | */ |
||
216 | private function check($content, $selector) |
||
230 | } |
||
231 |
This check marks private properties in classes that are never used. Those properties can be removed.