How to use a REST API from PHP using cURL | Full PHP cURL API tutorial

Поделиться
HTML-код
  • Опубликовано: 8 янв 2025

Комментарии • 57

  • @rshelfo1
    @rshelfo1 2 года назад +2

    been struggling for days to just create a simple cURL POST api client, thankyou so much this has been the MOST informative breakdown of doing just that.
    and unlike most other online resources, you dont write the code line by line, you build the app as it should be built. Amazing work

  • @tonyhomfray
    @tonyhomfray 2 года назад +6

    This gives such clear descriptions and full explanations of what you are doing and why at every step. Wonderful content. Thank you!

  • @johnnyvandenelzen2250
    @johnnyvandenelzen2250 2 года назад +2

    You sir, display such a clean and proper way of teaching. It is such a relief to find videos with these topics on RUclips that are spoken in proper English.
    Although I respect every individual that commits his/her time to produce free educational content, I am quite disappointed by the utter polution that exists on RUclips nowadays. I am speaking of all the educational videos that seem to be produced with the proper use of the English language at first (e.g. English title, English thumbnail, English useraccount, English description) but once started only lead to disappointment because the speaker is someone who barely speaks understandable English.
    I say this with a certain level of understanding yet quite the amount of resent because it makes my personal user experience on RUclips worse than it was before.
    Long story short, Dave Hollingworth, you are a godsend and I thank you for your videos!

  • @ilyamur885
    @ilyamur885 3 года назад +7

    Your tutorials are best, Dave!
    Keep up the good work!

  • @lexiriam
    @lexiriam 8 месяцев назад

    Your video tutorial is one of the best out there. Thank you for walking through and explaining the process in a slow, understandable method. I'm a subscriber!

  • @chadmasters3935
    @chadmasters3935 2 года назад

    Enjoyed your video. I'm trying to get back into PHP after a very long hiatus (PHP 4) . Thanks for your videos for seeing what's new under the sun.

  • @novakjetil
    @novakjetil 3 года назад +1

    great tutorial, Dave! Was just googling for this earlier today, and you posted this tonight! Cheers

  • @BoneyardHauntedHouse
    @BoneyardHauntedHouse 3 года назад +2

    Clear, concise, spot on!,,,, thank you very much for passing it on..

  • @RekhaR-s4k
    @RekhaR-s4k Год назад

    Hello Sir, Thank you so much for the tutorials such a clear and steady voice to follow and learn things. I ever seen such a tutorial before. very useful👏👏👏👍👍👍

  • @piyushakoliya72
    @piyushakoliya72 11 месяцев назад

    Amazing tutorial Dave.. very well explained..

  • @divineembassychildrenschoi6317
    @divineembassychildrenschoi6317 Год назад +1

    Wow this was really great iam happy i found you , you just gained a new w in the chat

  • @SLCODEGEN
    @SLCODEGEN 2 года назад +1

    Thank you!! such a neat & clean tutorial.

  • @michellemartinez-vc1mj
    @michellemartinez-vc1mj Год назад

    Thank you for this explanation. This helped me so much.

  • @athithyaparamesh8251
    @athithyaparamesh8251 2 года назад

    Just what I was looking for! Thanks a lot.

  • @bugsbunny9965
    @bugsbunny9965 2 года назад

    Easy to understand, Love it, Thank you Dave. 👍

  • @Iconic-scenes
    @Iconic-scenes 2 года назад

    Very good video, keep on the good work :)

  • @mullertm4778
    @mullertm4778 3 года назад +1

    thanks for this tutorial it's super useful keep it up

  • @SkLzaGaming
    @SkLzaGaming 3 года назад

    dave bro, u are just awesome. u will be great in future. remember.

  • @themonster4759
    @themonster4759 Год назад

    thanks for your effort this is helpful

  • @PrivateNaelyan
    @PrivateNaelyan Год назад

    Nicely explained!

  • @craigc5879
    @craigc5879 3 года назад

    Another excellent video

  • @sorasoralee2127
    @sorasoralee2127 3 года назад

    you help me a lot! thank you !

  • @mazs3364
    @mazs3364 Год назад

    Hi Dave, great video, thank you. was trying to show other details for the repository like the files. any hints would be appreciated. thanks

    • @dave-hollingworth
      @dave-hollingworth  Год назад

      You can adapt the code that shows a 404 to allow other URL segments, or use a third-party router if you have a lot of resource endpoints

  • @lilliannjihia8557
    @lilliannjihia8557 2 года назад

    Question: at 6:47 in running the foreach function, how do I begin troubleshooting if my code doesn't isolate the specific fields I'm interested in as yours did?

    • @dave-hollingworth
      @dave-hollingworth  2 года назад

      Try printing out the contents of the various variables you're using before, during and after the loop using var_dump for example

    • @lilliannjihia8557
      @lilliannjihia8557 2 года назад

      @@dave-hollingworth Lemme try that out. also some of the variables I'm looking for are nested within the primary array... How do I go about that?

    • @dave-hollingworth
      @dave-hollingworth  2 года назад

      var_dump will print out the full contents of a multidimensional array, and you can call it from within a loop

    • @lilliannjihia8557
      @lilliannjihia8557 2 года назад

      @@dave-hollingworth Hey Dave, I'm still having trouble isolating specific fields in my array response (my array response is very nested). For some reason it's not responding like in the tutorial with I identify the array indexes... I'm not sure why or whether it could be because of the structure of my array.

    • @dave-hollingworth
      @dave-hollingworth  2 года назад +1

      @@lilliannjihia8557 Try debugging it by using print_r for various different levels of the array

  • @b.sivakumar4328
    @b.sivakumar4328 2 года назад +1

    Thank you

  • @JuanBotes
    @JuanBotes 3 года назад

    Thanks for the great content \o/

  • @philadams9254
    @philadams9254 Год назад +1

    This is great. I've implemented this and your tutorial on creating a restful API in PHP, but I can't get cURL to connect to my API. For some reason, whether it's localhost or a proper server, because both are on the same server, it just won't connect. I think it could be some sort of firewall issue or maybe a PHP setting I don't know about. Any help on that would be appreciated.

    • @dave-hollingworth
      @dave-hollingworth  Год назад +1

      What happens when you try and connect, do you get any error messages at all?

    • @philadams9254
      @philadams9254 Год назад +1

      @@dave-hollingworth No, nothing, which is the most frustrating part! The cURL response is just empty with a 200 code and the script at the other end somehow gets called but also receives an empty request with no data. Bizarre!

    • @dave-hollingworth
      @dave-hollingworth  Год назад +1

      @@philadams9254 Try running the code from the video, there's a link in the description, see if that makes a difference - if so, try comparing yours to that code, see if you can spot a discrepancy that might be causing the error

    • @matteonicoli
      @matteonicoli Год назад

      I feel so stupid. I'm getting a blank screen. On my wamp (windows 11 display_errors=On) as well as on my live server. I am at a complete loss here. PHP directly copied, with new github access token.

    • @matteonicoli
      @matteonicoli Год назад +1

      I solved it. I went to work to hasty (which of course is never good combined with late night coding). I dowloaded your code from github and used file init_curl. Did paste the access token header but forgot to paste the url. In my production curl project I got a blank screen as well, while everything worked fine in Postman. Until I added this line CURLOPT_SSL_VERIFYPEER => false, I received data (so relieved). Felt helpless for 2 days. In any case, Dave Hollingworth and many thanks. Will be watching a lot more excellent tutorials from you in the future.

  • @deesolvero5548
    @deesolvero5548 2 года назад +1

    Hi Dave! I love your tutorials and I learned a lot from it. However, I am struggling in show.php because of undefined array in dl part.

    • @dave-hollingworth
      @dave-hollingworth  2 года назад

      Try comparing your code to the source code linked to in the description, see if there's a typo in your code maybe

  • @brendanhedges7591
    @brendanhedges7591 2 года назад +1

    Hi, A nice video, thank you. It helped a lot. How about making a video on retreaving data from an API with PHP/Curl and saving that data to a database, then retreaving the data and displaying it in HTML (for example on a users profile page). I'm thinking more of dynamic applications like Joomla.

    • @lilliannjihia8557
      @lilliannjihia8557 2 года назад

      Hey! Have you been able to work this out? I'm currently working on a problem that would require the same. But from what i can tell, if you isolate the variable names, you can run insert statements into your db in a straightforward manner.

  • @taelabaho
    @taelabaho 2 года назад

    this is gold

  • @tazefaze
    @tazefaze 2 года назад

    Thank you.

  • @butterfliessproud684
    @butterfliessproud684 2 месяца назад +1

    GOOD

  • @yousseflahmadi7665
    @yousseflahmadi7665 2 года назад

    Hi , i have a little question , when i try to echo some entities Like in the vedio for fullname name and discerption i get the error Cannot access offset of type string on string anyone have any ideas? Thank you in advance .

    • @dave-hollingworth
      @dave-hollingworth  2 года назад

      It means you're trying to use a string as an array: stackoverflow.com/a/20271518

  • @johnlopata217
    @johnlopata217 3 месяца назад

    🏆

  • @gennadyga2257
    @gennadyga2257 2 года назад +1

    What is IDE? Very simple and powerful)

    • @dave-hollingworth
      @dave-hollingworth  2 года назад +2

      I use Atom - atom.io/

    • @battowsai
      @battowsai 2 года назад

      @@dave-hollingworth as ATOM is getting retired this December, did you decide on a new IDE? im just starting to learn and would be interested on which alternative i might look for.

    • @dave-hollingworth
      @dave-hollingworth  2 года назад

      @@battowsai I recommend Visual Studio Code, it's free and cross platform. (I'm still going to use Atom for my videos for the foreseeable future as it's very minimalist and works well for video tutorials, but if you're coding yourself, I would use VSCode)

    • @battowsai
      @battowsai 2 года назад

      @@dave-hollingworth thank You for the answer. I guess i will try atom for the first project. This Tutorial will help me alot. The only problem i habe is that i Need to call three different rest api and compare the items.

  • @toano8855
    @toano8855 2 года назад

    hi bro, I have a question. How to curl without reload page?

    • @dave-hollingworth
      @dave-hollingworth  2 года назад

      cURL is called on the server, so you could call a page that used cURL using Ajax, or call the API directly from JavaScript

  • @michaelrorong
    @michaelrorong Год назад

    Bang kok lu mirip doctor strange