Skip to content

Commit a9712b1

Browse files
ADD FIRST DATA 💥
Add Main Files , Ready To Use in test Mode !!!
1 parent 3133fe6 commit a9712b1

8 files changed

Lines changed: 249 additions & 0 deletions

File tree

CheckFace.php

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: ikosar
5+
* Date: 19/04/2018
6+
* Time: 04:32 PM
7+
*/
8+
9+
namespace ikosar\LMFA;
10+
11+
12+
13+
use HTTP_Request2;
14+
use HttpException;
15+
16+
class CheckFace
17+
{
18+
// This Var must add to config file.
19+
20+
21+
public function getApiKey()
22+
{
23+
$this->api_key = config('lmfa.api_key');
24+
return $this->api_key;
25+
}
26+
27+
public function setUrl(array $url)
28+
{
29+
$this->url = $url;
30+
}
31+
32+
public function setHeaders(array $headers)
33+
{
34+
$this->headers = $headers;
35+
}
36+
37+
public function setParameters(array $parameters)
38+
{
39+
$this->parameters = $parameters;
40+
}
41+
42+
public function setMethod($method = 'post')
43+
{
44+
$this->method = $method;
45+
}
46+
47+
public function setBody($body = true, $is_simple_request = true)
48+
{
49+
$this->body = $body;
50+
$this->request_type = $is_simple_request;
51+
}
52+
53+
public function check()
54+
{
55+
if (isset($this->url) AND isset($this->headers) AND isset($this->parameters) AND isset($this->method) AND isset($this->body)) {
56+
$this->check = true;
57+
return true;
58+
}
59+
60+
$this->check = false;
61+
return false;
62+
}
63+
64+
public function send()
65+
{
66+
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
72+
{
73+
$request = new Http_Request2($this->url);
74+
}
75+
$url = $request->getUrl();
76+
$headers = $this->headers;
77+
$request->setHeader($headers);
78+
$parameters = $this->parameters;
79+
$url->setQueryVariables($parameters);
80+
switch ($this->method) {
81+
case "post":
82+
$mtd = HTTP_Request2::METHOD_POST;
83+
break;
84+
case "get":
85+
$mtd = HTTP_Request2::METHOD_GET;
86+
break;
87+
case "delete":
88+
$mtd = HTTP_Request2::METHOD_DELETE;
89+
break;
90+
case "put":
91+
$mtd = HTTP_Request2::METHOD_PUT;
92+
break;
93+
default:
94+
return "ERROR METHOD GIVEN WAS NOT VALID,ONLY LOWERCASE letter must used. ";
95+
break;
96+
};
97+
$request->setMethod($mtd);
98+
if ($this->request_type == true) {
99+
$simple = json_encode($this->url);
100+
$request->setBody($simple);
101+
} else {
102+
$request->setBody($this->body);
103+
}
104+
105+
try {
106+
$response = $request->send();
107+
return $response->getBody();
108+
} catch (HttpException $ex) {
109+
echo $ex;
110+
}
111+
112+
}
113+
return null;
114+
}
115+
116+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace ikosar\LMFA;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
class LaravelMicrosoftFaceApiProvider extends ServiceProvider
8+
{
9+
/**
10+
* Bootstrap the application services.
11+
*
12+
* @return void
13+
*/
14+
public function boot()
15+
{
16+
include __DIR__.'/route.php';
17+
$this->publishes([
18+
__DIR__.'/config/lmfa.php'=>config_path('/LMFA.php'),
19+
]);
20+
21+
}
22+
23+
/**
24+
* Register the application services.
25+
*
26+
* @return void
27+
*/
28+
public function register()
29+
{
30+
$this->app->make('ikosar\LMFA\LmfaController');
31+
}
32+
}

LmfaController.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace ikosar\LMFA;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Http\Request;
7+
8+
class LmfaController extends Controller
9+
{
10+
public function index(Request $request)
11+
{
12+
config('');
13+
}
14+
}

composer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "ikosar/lmfa",
3+
"description": "This Package Help You to connect to Microsoft Face APi.",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "ikosar",
9+
"email": "33053881+ikosar@users.noreply.github.com"
10+
}
11+
],
12+
"minimum-stability": "dev",
13+
"require": {
14+
"php":">=5.9.0",
15+
"pear/http_request2":"2.3.0"
16+
}
17+
}

config/lmfa.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: ikosar
5+
* Date: 23/04/2018
6+
* Time: 12:24 AM
7+
*/
8+
9+
return [
10+
/****
11+
* You Can Earn Your Api_key in " https://azure.microsoft.com/en-gb/try/cognitive-services/?api=face-api "
12+
* iKOSAR CYBER TEAM.CO
13+
* MIT Licence
14+
*/
15+
'api_key' => "",
16+
];
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateFacesTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('faces', function (Blueprint $table) {
17+
$table->increments('id');
18+
$this->string('face_id');
19+
$this->string('face_first_name')->nullable();
20+
$this->string('face_last_name')->nullable();
21+
$table->timestamps();
22+
});
23+
}
24+
25+
/**
26+
* Reverse the migrations.
27+
*
28+
* @return void
29+
*/
30+
public function down()
31+
{
32+
Schema::dropIfExists('faces');
33+
}
34+
}

models/Face.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace ikosar\LMFA\models;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Face extends Model
8+
{
9+
10+
}

route.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: mtheme.ir
5+
* Date: 23/04/2018
6+
* Time: 12:10 AM
7+
*/
8+
Route::get("/lmfa",function (){
9+
echo "Hi lolo";
10+
});

0 commit comments

Comments
 (0)