Skip to content

Instantly share code, notes, and snippets.

@aeknarinamn
Created July 3, 2021 19:38
Show Gist options
  • Save aeknarinamn/054a17e33164c457b93e74d45e3cb287 to your computer and use it in GitHub Desktop.
Save aeknarinamn/054a17e33164c457b93e74d45e3cb287 to your computer and use it in GitHub Desktop.
<?php
require_once __DIR__ . '/vendor/autoload.php';
/*Get Data From POST Http Request*/
$datas = file_get_contents('php://input');
/*Decode Json From LINE Data Body*/
$deCode = json_decode($datas,true);
$client = new MongoDB\Client(
'mongodb+srv://admin:[email protected]/myFirstDatabase?retryWrites=true&w=majority');
$db = $client->TEST;
$collection = $db->line_user_data;
$insertOneResult = $collection->insertOne(
$deCode
);
http_response_code(200);
// printf("Inserted %d document(s)\n", $insertOneResult->getInsertedCount());
// var_dump($insertOneResult->getInsertedId());
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment