What is a “cURL” and how do I execute it?










-1















I've been trying to make a Lyrebird application work. Mind that I only have basic javascript/php knowledge and have never done this so I tried implementing a cURL request noted on: "http://docs.lyrebird.ai". Needlessly to say that it doesn't work in javascript as well as PHP (even though I looked up on how to do it?)



I only need to run this example (the details are fake):



# Request #

curl -H 'Content-Type: application/json'
'https://avatar.lyrebird.ai/api/v0/token' -d
'
"grant_type": "authorization_code",
"client_id": "19qV2jZy1G44ifOxk6kgowAt9F0",
"client_secret": "19qnfRvIXdmQKhSbLG0CLxng5Mz",
"code": "19qozJe3hwnPvfl5xyNuR3MJ1NK"
'

# expected Response #

"access_token": "18QdNlaDvkzMbgQ5SXmKNGmexWo"



How do I run the request (programming language?) in a way I get the "Expected Response" noted in the example?










share|improve this question



















  • 1





    You have tagged this with both php and node.js. Are you using both? Several different request libraries you can use in node for this and php also has cUrl extension and Guzzle is helpful library in php

    – charlietfl
    Nov 13 '18 at 15:23












  • It's a program you run from a shell (at least, your example is): curl.haxx.se/docs/manual.html

    – mikeb
    Nov 13 '18 at 15:26











  • I honestly have no clue which tools to use. I use standard javascript and am using node for this project probably. But now I'm just figuring out how to get my access token

    – RickyR
    Nov 13 '18 at 15:26















-1















I've been trying to make a Lyrebird application work. Mind that I only have basic javascript/php knowledge and have never done this so I tried implementing a cURL request noted on: "http://docs.lyrebird.ai". Needlessly to say that it doesn't work in javascript as well as PHP (even though I looked up on how to do it?)



I only need to run this example (the details are fake):



# Request #

curl -H 'Content-Type: application/json'
'https://avatar.lyrebird.ai/api/v0/token' -d
'
"grant_type": "authorization_code",
"client_id": "19qV2jZy1G44ifOxk6kgowAt9F0",
"client_secret": "19qnfRvIXdmQKhSbLG0CLxng5Mz",
"code": "19qozJe3hwnPvfl5xyNuR3MJ1NK"
'

# expected Response #

"access_token": "18QdNlaDvkzMbgQ5SXmKNGmexWo"



How do I run the request (programming language?) in a way I get the "Expected Response" noted in the example?










share|improve this question



















  • 1





    You have tagged this with both php and node.js. Are you using both? Several different request libraries you can use in node for this and php also has cUrl extension and Guzzle is helpful library in php

    – charlietfl
    Nov 13 '18 at 15:23












  • It's a program you run from a shell (at least, your example is): curl.haxx.se/docs/manual.html

    – mikeb
    Nov 13 '18 at 15:26











  • I honestly have no clue which tools to use. I use standard javascript and am using node for this project probably. But now I'm just figuring out how to get my access token

    – RickyR
    Nov 13 '18 at 15:26













-1












-1








-1








I've been trying to make a Lyrebird application work. Mind that I only have basic javascript/php knowledge and have never done this so I tried implementing a cURL request noted on: "http://docs.lyrebird.ai". Needlessly to say that it doesn't work in javascript as well as PHP (even though I looked up on how to do it?)



I only need to run this example (the details are fake):



# Request #

curl -H 'Content-Type: application/json'
'https://avatar.lyrebird.ai/api/v0/token' -d
'
"grant_type": "authorization_code",
"client_id": "19qV2jZy1G44ifOxk6kgowAt9F0",
"client_secret": "19qnfRvIXdmQKhSbLG0CLxng5Mz",
"code": "19qozJe3hwnPvfl5xyNuR3MJ1NK"
'

# expected Response #

"access_token": "18QdNlaDvkzMbgQ5SXmKNGmexWo"



How do I run the request (programming language?) in a way I get the "Expected Response" noted in the example?










share|improve this question
















I've been trying to make a Lyrebird application work. Mind that I only have basic javascript/php knowledge and have never done this so I tried implementing a cURL request noted on: "http://docs.lyrebird.ai". Needlessly to say that it doesn't work in javascript as well as PHP (even though I looked up on how to do it?)



I only need to run this example (the details are fake):



# Request #

curl -H 'Content-Type: application/json'
'https://avatar.lyrebird.ai/api/v0/token' -d
'
"grant_type": "authorization_code",
"client_id": "19qV2jZy1G44ifOxk6kgowAt9F0",
"client_secret": "19qnfRvIXdmQKhSbLG0CLxng5Mz",
"code": "19qozJe3hwnPvfl5xyNuR3MJ1NK"
'

# expected Response #

"access_token": "18QdNlaDvkzMbgQ5SXmKNGmexWo"



How do I run the request (programming language?) in a way I get the "Expected Response" noted in the example?







javascript curl






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 15:24







RickyR

















asked Nov 13 '18 at 15:20









RickyRRickyR

446




446







  • 1





    You have tagged this with both php and node.js. Are you using both? Several different request libraries you can use in node for this and php also has cUrl extension and Guzzle is helpful library in php

    – charlietfl
    Nov 13 '18 at 15:23












  • It's a program you run from a shell (at least, your example is): curl.haxx.se/docs/manual.html

    – mikeb
    Nov 13 '18 at 15:26











  • I honestly have no clue which tools to use. I use standard javascript and am using node for this project probably. But now I'm just figuring out how to get my access token

    – RickyR
    Nov 13 '18 at 15:26












  • 1





    You have tagged this with both php and node.js. Are you using both? Several different request libraries you can use in node for this and php also has cUrl extension and Guzzle is helpful library in php

    – charlietfl
    Nov 13 '18 at 15:23












  • It's a program you run from a shell (at least, your example is): curl.haxx.se/docs/manual.html

    – mikeb
    Nov 13 '18 at 15:26











  • I honestly have no clue which tools to use. I use standard javascript and am using node for this project probably. But now I'm just figuring out how to get my access token

    – RickyR
    Nov 13 '18 at 15:26







1




1





You have tagged this with both php and node.js. Are you using both? Several different request libraries you can use in node for this and php also has cUrl extension and Guzzle is helpful library in php

– charlietfl
Nov 13 '18 at 15:23






You have tagged this with both php and node.js. Are you using both? Several different request libraries you can use in node for this and php also has cUrl extension and Guzzle is helpful library in php

– charlietfl
Nov 13 '18 at 15:23














It's a program you run from a shell (at least, your example is): curl.haxx.se/docs/manual.html

– mikeb
Nov 13 '18 at 15:26





It's a program you run from a shell (at least, your example is): curl.haxx.se/docs/manual.html

– mikeb
Nov 13 '18 at 15:26













I honestly have no clue which tools to use. I use standard javascript and am using node for this project probably. But now I'm just figuring out how to get my access token

– RickyR
Nov 13 '18 at 15:26





I honestly have no clue which tools to use. I use standard javascript and am using node for this project probably. But now I'm just figuring out how to get my access token

– RickyR
Nov 13 '18 at 15:26












3 Answers
3






active

oldest

votes


















2















curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS,
IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB,
SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work
without user interaction.
-- https://curl.haxx.se/docs/manpage.html




If I understood your question, what you´re trying to achieve is transform curl into your favorite (PHP) language?



There are many different ways to do this but here are my 2 favorites:



Postman



Postman allows you to import curl commands for later manipulation and also once your command has been imported you can actually generate code snippets from a large list of supported languages including PHP.



postmanpostman



Curl-to-PHP



This website has a copy-paste transformation approach.
curl to php






share|improve this answer






























    0














    curl is a linux-command to execute an http request to an url from command line. The tutorial, from which you posted the code, is just an example which creates a http-post request to the url.



    You should check the API of your programming lanuage (PHP or node.js) for how to do a http-post request. Here is a question for how to make an http post from node.js: How to make an HTTP POST request in node.js?






    share|improve this answer






























      0














      In js you can use e.g. fetch:



      var data=
      grant_type: "authorization_code",
      client_id: "19qV2jZy1G44ifOxk6kgowAt9F0",
      client_secret: "19qnfRvIXdmQKhSbLG0CLxng5Mz",
      code: "19qozJe3hwnPvfl5xyNuR3MJ1NK"

      fetch('https://avatar.lyrebird.ai/api/v0/token',
      method: 'POST',
      headers: "Content-Type": "application/json" ,
      credentials: 'include',
      body: JSON.stringify(data)
      ).then(function(res)
      return res.json();
      ).then(function(res)
      console.log(res);
      ).catch((e)=>alert (e))





      share|improve this answer

























      • Most API's that use client secrets are not CORS enabled so you aren't exposing credentials in front end

        – charlietfl
        Nov 13 '18 at 15:38












      • yes sorry, my copy and paste error

        – charly1212
        Nov 13 '18 at 15:43










      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284143%2fwhat-is-a-curl-and-how-do-i-execute-it%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2















      curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS,
      IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB,
      SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work
      without user interaction.
      -- https://curl.haxx.se/docs/manpage.html




      If I understood your question, what you´re trying to achieve is transform curl into your favorite (PHP) language?



      There are many different ways to do this but here are my 2 favorites:



      Postman



      Postman allows you to import curl commands for later manipulation and also once your command has been imported you can actually generate code snippets from a large list of supported languages including PHP.



      postmanpostman



      Curl-to-PHP



      This website has a copy-paste transformation approach.
      curl to php






      share|improve this answer



























        2















        curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS,
        IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB,
        SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work
        without user interaction.
        -- https://curl.haxx.se/docs/manpage.html




        If I understood your question, what you´re trying to achieve is transform curl into your favorite (PHP) language?



        There are many different ways to do this but here are my 2 favorites:



        Postman



        Postman allows you to import curl commands for later manipulation and also once your command has been imported you can actually generate code snippets from a large list of supported languages including PHP.



        postmanpostman



        Curl-to-PHP



        This website has a copy-paste transformation approach.
        curl to php






        share|improve this answer

























          2












          2








          2








          curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS,
          IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB,
          SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work
          without user interaction.
          -- https://curl.haxx.se/docs/manpage.html




          If I understood your question, what you´re trying to achieve is transform curl into your favorite (PHP) language?



          There are many different ways to do this but here are my 2 favorites:



          Postman



          Postman allows you to import curl commands for later manipulation and also once your command has been imported you can actually generate code snippets from a large list of supported languages including PHP.



          postmanpostman



          Curl-to-PHP



          This website has a copy-paste transformation approach.
          curl to php






          share|improve this answer














          curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS,
          IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB,
          SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work
          without user interaction.
          -- https://curl.haxx.se/docs/manpage.html




          If I understood your question, what you´re trying to achieve is transform curl into your favorite (PHP) language?



          There are many different ways to do this but here are my 2 favorites:



          Postman



          Postman allows you to import curl commands for later manipulation and also once your command has been imported you can actually generate code snippets from a large list of supported languages including PHP.



          postmanpostman



          Curl-to-PHP



          This website has a copy-paste transformation approach.
          curl to php







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 15:30









          Oscar NevarezOscar Nevarez

          542617




          542617























              0














              curl is a linux-command to execute an http request to an url from command line. The tutorial, from which you posted the code, is just an example which creates a http-post request to the url.



              You should check the API of your programming lanuage (PHP or node.js) for how to do a http-post request. Here is a question for how to make an http post from node.js: How to make an HTTP POST request in node.js?






              share|improve this answer



























                0














                curl is a linux-command to execute an http request to an url from command line. The tutorial, from which you posted the code, is just an example which creates a http-post request to the url.



                You should check the API of your programming lanuage (PHP or node.js) for how to do a http-post request. Here is a question for how to make an http post from node.js: How to make an HTTP POST request in node.js?






                share|improve this answer

























                  0












                  0








                  0







                  curl is a linux-command to execute an http request to an url from command line. The tutorial, from which you posted the code, is just an example which creates a http-post request to the url.



                  You should check the API of your programming lanuage (PHP or node.js) for how to do a http-post request. Here is a question for how to make an http post from node.js: How to make an HTTP POST request in node.js?






                  share|improve this answer













                  curl is a linux-command to execute an http request to an url from command line. The tutorial, from which you posted the code, is just an example which creates a http-post request to the url.



                  You should check the API of your programming lanuage (PHP or node.js) for how to do a http-post request. Here is a question for how to make an http post from node.js: How to make an HTTP POST request in node.js?







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 13 '18 at 15:33









                  AlexAlex

                  81347




                  81347





















                      0














                      In js you can use e.g. fetch:



                      var data=
                      grant_type: "authorization_code",
                      client_id: "19qV2jZy1G44ifOxk6kgowAt9F0",
                      client_secret: "19qnfRvIXdmQKhSbLG0CLxng5Mz",
                      code: "19qozJe3hwnPvfl5xyNuR3MJ1NK"

                      fetch('https://avatar.lyrebird.ai/api/v0/token',
                      method: 'POST',
                      headers: "Content-Type": "application/json" ,
                      credentials: 'include',
                      body: JSON.stringify(data)
                      ).then(function(res)
                      return res.json();
                      ).then(function(res)
                      console.log(res);
                      ).catch((e)=>alert (e))





                      share|improve this answer

























                      • Most API's that use client secrets are not CORS enabled so you aren't exposing credentials in front end

                        – charlietfl
                        Nov 13 '18 at 15:38












                      • yes sorry, my copy and paste error

                        – charly1212
                        Nov 13 '18 at 15:43















                      0














                      In js you can use e.g. fetch:



                      var data=
                      grant_type: "authorization_code",
                      client_id: "19qV2jZy1G44ifOxk6kgowAt9F0",
                      client_secret: "19qnfRvIXdmQKhSbLG0CLxng5Mz",
                      code: "19qozJe3hwnPvfl5xyNuR3MJ1NK"

                      fetch('https://avatar.lyrebird.ai/api/v0/token',
                      method: 'POST',
                      headers: "Content-Type": "application/json" ,
                      credentials: 'include',
                      body: JSON.stringify(data)
                      ).then(function(res)
                      return res.json();
                      ).then(function(res)
                      console.log(res);
                      ).catch((e)=>alert (e))





                      share|improve this answer

























                      • Most API's that use client secrets are not CORS enabled so you aren't exposing credentials in front end

                        – charlietfl
                        Nov 13 '18 at 15:38












                      • yes sorry, my copy and paste error

                        – charly1212
                        Nov 13 '18 at 15:43













                      0












                      0








                      0







                      In js you can use e.g. fetch:



                      var data=
                      grant_type: "authorization_code",
                      client_id: "19qV2jZy1G44ifOxk6kgowAt9F0",
                      client_secret: "19qnfRvIXdmQKhSbLG0CLxng5Mz",
                      code: "19qozJe3hwnPvfl5xyNuR3MJ1NK"

                      fetch('https://avatar.lyrebird.ai/api/v0/token',
                      method: 'POST',
                      headers: "Content-Type": "application/json" ,
                      credentials: 'include',
                      body: JSON.stringify(data)
                      ).then(function(res)
                      return res.json();
                      ).then(function(res)
                      console.log(res);
                      ).catch((e)=>alert (e))





                      share|improve this answer















                      In js you can use e.g. fetch:



                      var data=
                      grant_type: "authorization_code",
                      client_id: "19qV2jZy1G44ifOxk6kgowAt9F0",
                      client_secret: "19qnfRvIXdmQKhSbLG0CLxng5Mz",
                      code: "19qozJe3hwnPvfl5xyNuR3MJ1NK"

                      fetch('https://avatar.lyrebird.ai/api/v0/token',
                      method: 'POST',
                      headers: "Content-Type": "application/json" ,
                      credentials: 'include',
                      body: JSON.stringify(data)
                      ).then(function(res)
                      return res.json();
                      ).then(function(res)
                      console.log(res);
                      ).catch((e)=>alert (e))






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 13 '18 at 15:47

























                      answered Nov 13 '18 at 15:33









                      charly1212charly1212

                      13518




                      13518












                      • Most API's that use client secrets are not CORS enabled so you aren't exposing credentials in front end

                        – charlietfl
                        Nov 13 '18 at 15:38












                      • yes sorry, my copy and paste error

                        – charly1212
                        Nov 13 '18 at 15:43

















                      • Most API's that use client secrets are not CORS enabled so you aren't exposing credentials in front end

                        – charlietfl
                        Nov 13 '18 at 15:38












                      • yes sorry, my copy and paste error

                        – charly1212
                        Nov 13 '18 at 15:43
















                      Most API's that use client secrets are not CORS enabled so you aren't exposing credentials in front end

                      – charlietfl
                      Nov 13 '18 at 15:38






                      Most API's that use client secrets are not CORS enabled so you aren't exposing credentials in front end

                      – charlietfl
                      Nov 13 '18 at 15:38














                      yes sorry, my copy and paste error

                      – charly1212
                      Nov 13 '18 at 15:43





                      yes sorry, my copy and paste error

                      – charly1212
                      Nov 13 '18 at 15:43

















                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284143%2fwhat-is-a-curl-and-how-do-i-execute-it%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      這個網誌中的熱門文章

                      Barbados

                      How to read a connectionString WITH PROVIDER in .NET Core?

                      Node.js Script on GitHub Pages or Amazon S3