@@ -12,9 +12,14 @@ class TextRuApi
12
12
13
13
private static $ allowed_options_get = ["exceptdomain " , "excepturl " , "visible " , "copying " , "callback " ];
14
14
15
- private function __construct ($ userkey )
15
+ public function __construct ($ userkey, $ default_options = [] )
16
16
{
17
17
$ this ->userkey = $ userkey ;
18
+
19
+ foreach ($ default_options as $ key => $ value ) {
20
+ if (!in_array ($ key , self ::$ allowed_options_get )) throw new WrongParameterException ("Unknown option " . $ key . " provided " , 400122 );
21
+ }
22
+ $ this ->default_options = $ default_options ;
18
23
}
19
24
20
25
public function userkey ($ userkey = null )
@@ -33,7 +38,7 @@ public static function add($userkey, $text, $options = [])
33
38
if (!is_array ($ options )) throw new WrongParameterException ("Options param must be array " , 400124 );
34
39
35
40
foreach ($ options as $ key => $ value ) {
36
- if (!in_array ($ key , $ this ::$ allowed_options_get )) throw new WrongParameterException ("Unknown option " . $ key . " provided " , 400125 );
41
+ if (!in_array ($ key , self ::$ allowed_options_get )) throw new WrongParameterException ("Unknown option " . $ key . " provided " , 400125 );
37
42
}
38
43
39
44
$ post_options = ["userkey " => $ userkey , "text " => $ text ];
@@ -54,6 +59,11 @@ public static function add($userkey, $text, $options = [])
54
59
55
60
}
56
61
62
+ public function adds ($ text , $ options = [])
63
+ {
64
+ return $ this ::add ($ this ->userkey , $ text , $ options );
65
+ }
66
+
57
67
public static function get ($ userkey , $ uid , $ jsonvisible = null )
58
68
{
59
69
if ((empty ($ userkey )) || (empty ($ uid ))) throw new WrongParameterException ("Required params is empty " , 400131 );
@@ -82,6 +92,11 @@ public static function get($userkey, $uid, $jsonvisible = null)
82
92
return $ result ;
83
93
}
84
94
95
+ public static function gets ($ uid , $ jsonvisible = null )
96
+ {
97
+ return $ this ::add ($ this ->userkey , $ uid , $ jsonvisible );
98
+ }
99
+
85
100
public static function sendCurl ($ postfields , $ url = 'http://api.text.ru/post ' )
86
101
{
87
102
if (is_array ($ postfields )) $ postfields = http_build_query ($ postfields , '' , '& ' );
0 commit comments