Created
November 5, 2020 19:10
-
-
Save BlackScorp/5b603ad7bdb738feaaa2dae8c99cd7f3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
if(isset($_COOKIE['Token'])){ | |
session_id($_COOKIE['Token']); //sette den token als ID | |
} | |
session_start(); //Lade session | |
$userAcces = $_SESSION['userAccess'];//wenn Token valide ist, stehen in $_SESSION daten drin | |
$responseArray = []; | |
$responseArray = array_merge($responseArray,[$_SERVER['REQUEST_METHOD']]); | |
$responseArray = array_merge($responseArray,$_GET); | |
$responseArray = array_merge($responseArray,$_POST); | |
$responseArray = array_merge($responseArray,$_COOKIE); | |
header('Content-Type:application/json;charset=utf-8'); | |
echo json_encode($responseArray); |
This file contains hidden or 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 | |
//Daten zum senden | |
$data = [ | |
'todoTitle'=>'foo', | |
'todoContent'=>'bar' | |
]; | |
//Token | |
$token = 'Token=1asd54asd1845a1d3a2s1d'; | |
//URL | |
$curl = curl_init('https://deineURl.com/api.php/todo/create'); | |
curl_setopt_array($curl,[ | |
CURLOPT_CUSTOMREQUEST=>"POST", | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_HTTPHEADER=>[ | |
'Cookie: '.$cookie //Header informationen | |
], | |
CURLOPT_POSTFIELDS => json_encode($data) //Daten als JSON senden | |
]); | |
//Antwort vom Server | |
$response = curl_exec($curl); | |
var_dump($response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment