Created
June 1, 2019 21:20
-
-
Save handhikadj/c66faa9a1572323a03a712cd37dc909d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use GuzzleHttp\Exception\ConnectException; | |
require_once("vendor/autoload.php"); | |
/* Start to develop here. Best regards https://php-download.com/ */ | |
function connectMyApi() { | |
$nama = $_GET['namaku']; | |
$appPath = "192.168.0.2/laravel-api-passport/public"; | |
try { | |
$client = new GuzzleHttp\Client(); | |
$clientPost = $client->post("{$appPath}/posttodb", [ | |
'body' => [ | |
'name_product' => $nama | |
] | |
]); | |
return json_encode(['data' => $clientPost]); | |
} catch (ConnectException $e) { | |
return json_encode(['data' => $e->getMessage()]); | |
} | |
} | |
echo connectMyApi(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment