@@ -7,6 +7,7 @@ class Check {
77 private $ endpoint = 'https://api.sightengine.com/ ' ;
88 private $ http ;
99 private $ models ;
10+ private $ url = '1.0/check.json ' ;
1011
1112 function __construct ($ api_user , $ api_secret , $ models ) {
1213 $ this ->api_user = $ api_user ;
@@ -15,22 +16,23 @@ function __construct($api_user, $api_secret, $models) {
1516 $ this ->models = implode (", " , $ models );
1617 }
1718
18- public function image ($ image ) {
19- $ url = '1.0/check.json ' ;
19+ public function set_file ($ image ) {
20+ $ file = fopen ($ image , 'r ' );
21+ $ r = $ this ->http ->request ('POST ' , $ this ->url , ['query ' => ['api_user ' => $ this ->api_user , 'api_secret ' => $ this ->api_secret , 'models ' => $ this ->models ],'multipart ' => [['name ' => 'media ' ,'contents ' => $ file ]]]);
2022
21- if (filter_var ($ image , FILTER_VALIDATE_URL )) {
22- $ r = $ this ->http ->request ('GET ' , $ url , ['query ' => ['api_user ' => $ this ->api_user ,
23- 'api_secret ' => $ this ->api_secret ,
24- 'models ' => $ this ->models ,
25- 'url ' => $ image ]]);
23+ return json_decode ($ r ->getBody ());
24+ }
25+
26+ public function set_url ($ imageUrl ) {
27+ $ r = $ this ->http ->request ('GET ' , $ this ->url , ['query ' => ['api_user ' => $ this ->api_user , 'api_secret ' => $ this ->api_secret , 'models ' => $ this ->models ,'url ' => $ imageUrl ]]);
28+
29+ return json_decode ($ r ->getBody ());
30+ }
2631
27- return json_decode ($ r ->getBody ());
28- } else {
29- $ file = fopen ($ image , 'r ' );
30- $ r = $ this ->http ->request ('POST ' , $ url , ['query ' => ['api_user ' => $ this ->api_user , 'api_secret ' => $ this ->api_secret , 'models ' => $ this ->models ],'multipart ' => [['name ' => 'media ' ,'contents ' => $ file ]]]);
32+ public function set_bytes ($ image ) {
33+ $ r = $ this ->http ->request ('POST ' , $ this ->url , ['query ' => ['api_user ' => $ this ->api_user , 'api_secret ' => $ this ->api_secret , 'models ' => $ this ->models ],'multipart ' => [['name ' => 'media ' ,'contents ' => $ image ]]]);
3134
32- return json_decode ($ r ->getBody ());
33- }
35+ return json_decode ($ r ->getBody ());
3436 }
3537
3638 public function video ($ videoUrl , $ callbackUrl ) {
0 commit comments