Skip to content

Commit 220247e

Browse files
Some Edits 🎈
1 parent 32d2cdf commit 220247e

3 files changed

Lines changed: 58 additions & 11 deletions

File tree

CheckFace.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ public function getApiKey()
2424
return $this->api_key;
2525
}
2626

27-
public function setUrl(array $url)
27+
public function setUrl($url = "https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect")
2828
{
2929
$this->url = $url;
3030
}
31+
public function setImage(array $image)
32+
{
33+
$this->image = $image;
34+
}
3135

3236
public function setHeaders(array $headers)
3337
{
@@ -64,14 +68,13 @@ public function check()
6468
public function send()
6569
{
6670
if ($this->check) {
67-
if ($this->request_type == true)
68-
{
69-
$request = new Http_Request2('https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect');
70-
}
71-
else
71+
if ($this->url)
7272
{
7373
$request = new Http_Request2($this->url);
7474
}
75+
else {
76+
$request = new Http_Request2('https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect');
77+
}
7578
$url = $request->getUrl();
7679
$headers = $this->headers;
7780
$request->setHeader($headers);
@@ -96,7 +99,7 @@ public function send()
9699
};
97100
$request->setMethod($mtd);
98101
if ($this->request_type == true) {
99-
$simple = json_encode($this->url);
102+
$simple = json_encode($this->image);
100103
$request->setBody($simple);
101104
} else {
102105
$request->setBody($this->body);

README.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,48 @@
22
This Package Help You To Connect To Microsoft Face APi
33
by Mohammad Najafian
44
# Installation
5-
### install With Composer
6-
``` composer require ikosar/lmfa ```
7-
After :
5+
#### install With Composer
6+
```
7+
composer require ikosar/lmfa
8+
```
9+
#### After :
810

9-
``` php artisan vendor:publish ```
11+
```
12+
php artisan vendor:publish
13+
```
14+
# Config
15+
Open ``` lmfa.php ``` in config folder in laravel root then you can enter you'r `` api_key `` in this file !
16+
# Usage
17+
#### Normal Request (Return To You Face's info)
18+
##### 1 . First we need to do this :
19+
```
20+
$face = new CheckFace();
21+
```
22+
##### 2 . We Set The Url :
23+
if you want to customize the url Do this : (default : https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect)
24+
````
25+
$face->setUrl($url);
26+
````
27+
28+
```
29+
$image = array(
30+
'url' => 'http://cdn-tehran.wisgoon.com/dlir-s3/10531466806488528869.JPG',
31+
);
32+
33+
$face = new CheckFace();
34+
$face->setUrl($image);
35+
$face->setMethod("post");
36+
$face->setHeaders(array(
37+
'Content-Type' => 'application/json',
38+
'Ocp-Apim-Subscription-Key' => $face->getApiKey(),
39+
));
40+
$face->setParameters(array(
41+
'returnFaceId' => 'true',
42+
'returnFaceLandmarks' => 'false',
43+
'returnFaceAttributes' => 'age,gender,glasses,smile,noise,hair,accessories,emotion,makeup',
44+
));
45+
$face->setBody();
46+
$face->check();
47+
$face->send();
48+
49+
```

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
"email": "33053881+ikosar@users.noreply.github.com"
1010
}
1111
],
12+
"repositories": [
13+
{"type": "composer", "url": "https://repo.packagist.com/lmfa/"},
14+
{"packagist.org": false}
15+
],
1216
"minimum-stability": "dev",
1317
"require": {
1418
"php":">=5.9.0",

0 commit comments

Comments
 (0)