in Education by
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)

1 Answer

0 votes
by
After spending so much time and way I came across the best solution for this issues is just use this git repository with the help of the composer, and it works awesome, but you must have some knowledge about the composer and how to install and use the libraries with the help of auto loading useful file. Here is the link for the repository. They have already give a proper example using OAuth2 provider also. GraphQL-Client Hope it helps. Here is the sample code: <?php $client = \Softonic\GraphQL\ClientBuilder::build('https://catalog.swarm.pub.softonic.one/graphql'); $query = <<<'QUERY' query GetFooBar($idFoo: String, $idBar: String) { foo(id: $idFoo) { id_foo bar (id: $idBar) { id_bar } } } QUERY; $variables = [ 'idFoo' => 'foo', 'idBar' => 'bar', ]; $response = $client->query($query, $variables); ?>

Related questions

0 votes
    How can we POST JSON data with cURL?...
asked Jan 11, 2021 in Technology by JackTerrance
0 votes
    How can I transform QraphQl query to HTTP get request for example http://localhost:4000/? query GetClient { ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    URL is http://*.*.*.*/100/?id=1&version=1 params is {"cityId": "110000", "query": {" ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 27, 2022 in Education by JackTerrance
0 votes
    I have the following code : curl -X PUT -u ":" \ -H "Content-Type: application/json" \ --data '{"alias": "myalias"} ... and i don't know what is the problem. this is what i tried...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    first of all,i am fairly new with spring mvc so .. how springmvc find the right class to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I am working on my first Android Application. What I am trying to do is a POST request to a REST ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I am very new to creating and consuming REST web services in C#. I have programmed the data I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I am new to PHP as you may be able to tell from the question. What I have is an iOS application ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    When i use graph api to post a picture, everything is ok. The photo is right in the album. The ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 16, 2022 in Education by JackTerrance
0 votes
    @RequestMapping annotation is used to map a HTTP request method (GET or POST) to a specific class or method in the ... which will handle the respective request. A. True B. False...
asked Nov 8, 2022 in Education by JackTerrance
0 votes
    I want to get the search result using scrapy post request after giving the input to CP Number as 16308 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    Is it possible to make a timeout of 3 seconds in a post request ? How ? My code for the moment ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I am trying to calculate the progress of a file upload, so I was using Superagent. I was able to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    I am new to jmeter. I have been experimenting on creating a jmeter script manually by inspecting the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
...