Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
MP-Tsel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dzulfiqar Ridha
MP-Tsel
Commits
7ec3f7a6
Commit
7ec3f7a6
authored
Apr 04, 2019
by
Ghitha Dinan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test request
parent
f4ae20a3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
2 deletions
+81
-2
_ide_helper.php
_ide_helper.php
+0
-0
MResponse.php
app/Classes/MResponse.php
+17
-0
MasheryController.php
app/Http/Controllers/MasheryController.php
+59
-0
web.php
routes/web.php
+5
-2
No files found.
_ide_helper.php
0 → 100644
View file @
7ec3f7a6
This diff is collapsed.
Click to expand it.
app/Classes/MResponse.php
0 → 100644
View file @
7ec3f7a6
<?php
/**
* Created by PhpStorm.
* User: gets
* Date: 4/4/2019
* Time: 1:15 PM
*/
namespace
App\Classes
;
class
MResponse
{
public
$success
=
false
;
public
$message
=
''
;
public
$data
=
[];
}
app/Http/Controllers/MasheryController.php
0 → 100644
View file @
7ec3f7a6
<?php
/**
* Created by PhpStorm.
* User: gets
* Date: 4/4/2019
* Time: 1:08 PM
*/
namespace
App\Http\Controllers
;
use
App\Classes\MResponse
;
use
GuzzleHttp\Client
;
class
MasheryController
extends
Controller
{
public
function
getToken
()
{
$mResponse
=
new
MResponse
();
$statusCode
=
200
;
try
{
$client
=
new
Client
([
'base_uri'
=>
'https://api.mashery.com/'
,
'auth'
=>
[
'y4a5rz5ccv374qu33558f65b'
,
'yuZRnvKvYY'
],
'headers'
=>
[
'Authorization'
=>
'Basic eTRhNXJ6NWNjdjM3NHF1MzM1NThmNjViOnl1WlJudkt2WVk='
,
'Content-Type'
=>
'application/x-www-form-urlencoded'
],
'http_errors'
=>
true
]);
$response
=
$client
->
request
(
'POST'
,
'https://api.mashery.com/v3/token'
,
[
'form_params'
=>
[
'grant_type'
=>
'password'
,
'username'
=>
'marketplace.dev'
,
'password'
=>
'Marketplace123'
,
'scope'
=>
'71338066-f062-4feb-84b7-6547f0dc4e82'
]
]);
$resBody
=
json_decode
(
$response
->
getBody
()
->
getContents
(),
true
);
if
(
$response
->
getStatusCode
()
!=
200
)
{
$statusCode
=
$response
->
getStatusCode
();
$mResponse
->
message
=
$resBody
;
}
else
{
$mResponse
->
success
=
true
;
$mResponse
->
message
=
'success'
;
$mResponse
->
data
=
$resBody
;
}
}
catch
(
\Exception
$e
)
{
$statusCode
=
500
;
$mResponse
->
message
=
$e
->
getMessage
();
}
return
response
()
->
json
(
$mResponse
,
$statusCode
);
}
}
routes/web.php
View file @
7ec3f7a6
...
...
@@ -17,4 +17,8 @@ $router->get('/', function () use ($router) {
$router
->
get
(
'/token'
,
'MasheryGetTokenController@getToken'
);
$router
->
get
(
'/getUser'
,
'MasheryGetUserController@getUser'
);
\ No newline at end of file
$router
->
get
(
'/getUser'
,
'MasheryGetUserController@getUser'
);
$router
->
group
([
'prefix'
=>
'mashery'
],
function
()
use
(
$router
)
{
$router
->
get
(
'token'
,
'MasheryController@getToken'
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment