This is a cURL function that can send or retrieve data. It should work with any PHP app that supports OAuth:
function jwt_request($url,$token, $post) {
header('Content-Type: application/json'); // Specify the type of data
$ch = curl_init($url); // Initialise cURL
$post = json_encode($post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1); // Specify the request method as POS
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); // Set the posted fields
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // This will follow any redirects
$result = curl_exec($ch); // Execute the cURL statement
curl_close($ch); // Close the cURL connection
return ($result); // Return the received data
}
// I am running in localhost
$url = "http://localhost:3000/graphql";
// This is what query i am running
$post = '{"query": "query { login(username:"
[email protected]",password: "abbas") { userID token } }" }';
// This is the function i am using in above
$json = jwt_request($url,$token, $post);
echo "
";
print_r($json); // here printing
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)