Skip to content

Commit 15a3dfc

Browse files
Change Too 💯
1 parent 220247e commit 15a3dfc

2 files changed

Lines changed: 83 additions & 23 deletions

File tree

CheckFace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function setMethod($method = 'post')
4848
$this->method = $method;
4949
}
5050

51-
public function setBody($body = true, $is_simple_request = true)
51+
public function setBody(array $body, $is_simple_request = true)
5252
{
5353
$this->body = $body;
5454
$this->request_type = $is_simple_request;

README.md

Lines changed: 82 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,95 @@ by Mohammad Najafian
1515
Open ``` lmfa.php ``` in config folder in laravel root then you can enter you'r `` api_key `` in this file !
1616
# Usage
1717
#### Normal Request (Return To You Face's info)
18-
##### 1 . First we need to do this :
18+
##### 1 . First we need to do this :100: :
1919
```
2020
$face = new CheckFace();
2121
```
2222
##### 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)
23+
if you want to customize the url Do this :100: : (default : https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect)
2424
````
2525
$face->setUrl($url);
2626
````
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();
27+
##### 3 . Also Set Request Type ( post , get , delete , put ) :100: :
28+
To this step we set the request's type (only lowercase) :
29+
````
30+
$face->setMethod("post");
31+
````
32+
##### 4 . Set Headers :100: :
33+
We Must to set headers to use Microsoft's Face APi (only lowercase) :
34+
###### if you want to put APi_key in Headers or Parameters Use This :
35+
````
36+
$face->getApiKey();
37+
````
38+
````
39+
$face->setHeaders(array(
40+
'Content-Type' => 'application/json',
41+
'Ocp-Apim-Subscription-Key' => $face->getApiKey(),
42+
));
43+
````
44+
##### 5 . Set Parameters :100: :
45+
To this step we can set the Parameters :
46+
````
47+
$face->setParameters(array(
48+
'returnFaceId' => 'true', // Recommended : True
49+
'returnFaceLandmarks' => 'false', // Very information about face sizes
50+
'returnFaceAttributes' => 'age,gender,glasses,smile,noise,hair,accessories,emotion,makeup', // Your Requsted info
51+
));
52+
````
53+
######You can set these in the returnFaceAttributes in parameters
54+
Some Face Attributes : age , gender , glasses , smile , noise , hair , accessories , emotion , makeup ...
55+
//
56+
##### 6 . Set image :100: :
57+
######Then , we need to set image :-) :
58+
We must to put image URL in the array Like This.
59+
````
60+
$image = array(
61+
'url' => 'http://cdn-tehran.wisgoon.com/dlir-s3/10531466806488528869.JPG',
62+
);
63+
$face->setBody($image,true); // Set Image
64+
65+
````
66+
##### 7 . Check Request to complete set :100: :
67+
We must to Check Before ```$face->send()```.
68+
````
69+
$face->check();
70+
$face->send();
71+
````
72+
##### 8 . Get Face Information in JSON :100: :
73+
Do This :
74+
````
4675
$face->check();
47-
$face->send();
76+
$result = $face->send();
77+
// Now JSON in $result
78+
return $result;
79+
````
80+
# Finish And a Example:
81+
82+
83+
```
84+
$image = array(
85+
'url' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Donald_Trump_August_19%2C_2015_%28cropped%29.jpg/245px-Donald_Trump_August_19%2C_2015_%28cropped%29.jpg',
86+
);
87+
88+
$face = new CheckFace();
89+
$face->setUrl($image);
90+
$face->setMethod("post");
91+
$face->setHeaders(array(
92+
'Content-Type' => 'application/json',
93+
'Ocp-Apim-Subscription-Key' => $face->getApiKey(),
94+
));
95+
$face->setParameters(array(
96+
'returnFaceId' => 'true',
97+
'returnFaceLandmarks' => 'false',
98+
'returnFaceAttributes' => 'age,gender,glasses,smile,noise,hair,accessories,emotion,makeup',
99+
));
100+
$face->setBody($image);
101+
$face->check();
102+
$result = $face->send();
48103
49104
```
105+
#Licence
106+
This Project is under the MIT Licence
107+
#Read About Microsoft Face Api
108+
###Types of requests
109+
https://westcentralus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236

0 commit comments

Comments
 (0)