SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 28

Thread: cURL

  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,529
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    cURL

    What exactly is cURL?

    And why would you use it to submit payment information to a Payment Gateway as opposed to some other method or tool?


    Debbie

  2. #2
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Client Url library.

    It's basically PHPs implementation of http. It's basically ready to go. You tell it where you're going, what data you're submitting, what options you want and it does it for you.

    Job done.

    You could use other scripts.. I had one which was over 300 lines in length for one function.. and even then it sometimes errors. You basically have to trust that the person who wrote it knew what they were doing and knew all about http headers etc. With cURL you don't need to worry as long as you done your bit correctly it will do its bit with no problems.

    cURL also makes it very easy to send information by POST. Anyone can use get_file_contents() to get a url by GET but sending POST data is far harder since its not passed in the url as a parameter. Again cURL makes it a lot easier to do this.

    The first time I came across cURL I wasn't terribly up for it as it looked rather complex to use. In reality its like any other php code. You need a few lines to tell it what you're doing and thats it - once it works job done. The php manual link I gave you at the top will be very useful to you as it will also have lots of user contributed notes and code samples.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  3. #3
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    What other method or tool Debbie? cURL is pretty flexible, more so than most of its alternatives.

    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  4. #4
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,529
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AnthonySterling View Post
    What other method or tool Debbie?
    I asked first!


    cURL is pretty flexible, more so than most of its alternatives.

    I already looked it up on PHP.net and that didn't really help.

    I guess I wasn't really sure what it is, or why I care about it?!

    For submitting a payment for, I guess you need (??) cURL to submit the data using POST and HTTPS, is that it?

    Just trying to understand it, and how it might relate to the Payment Gateway I may be using.

    Like, is cURL an issue on my side of the equation (e.g. on my web host), or is it something my Payment Gateway has to have or approve?



    Debbie

  5. #5
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cURL is a feature of PHP. PHP is on your server so its something that YOU need to use.

    cURL basically acts as a browser on the internet. It does the same thing as Internet Explorer, Firefox, Netscape, Seamonkey, Chrome, etc in that it makes http requests, sends data and headers and then receives a http response like any browser would. The only difference is that cURL doesn't display the result because it isn't a display engine. It literally just downloads hyertext and file streams as instructed by you.

    Yes you will need to use it and yes it will almost certainly be available to you (assuming your host has it enabled). cURL is a good thing and its one of PHPs best tools because it makes internet communication very easy as you don't have to write your own socket code, header processing code etc.

    If looking it up on php.net didn't really help then you're probably not understanding it properly. Read it and then re-read it until it starts to make sense. I know the name doesn't do it any favours but you have to remember that it is basically does the same as internet explorer without a display.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  6. #6
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,529
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tangoforce View Post
    cURL is a feature of PHP. PHP is on your server so its something that YOU need to use.

    cURL basically acts as a browser on the internet. It does the same thing as Internet Explorer, Firefox, Netscape, Seamonkey, Chrome, etc in that it makes http requests, sends data and headers and then receives a http response like any browser would. The only difference is that cURL doesn't display the because it isn't a display engine. It literally just downloads hyertext and file streams as instructed by you.
    So how would you submit a payment form normally if cURL didn't exist?

    Is it better than using the browser to do that?


    If looking it up on php.net didn't really help then you're probably not understanding it properly. Read it and then re-read it until it starts to make sense. I know the name doesn't do it any favours but you have to remember that it is basically does the same as internet explorer without a display.
    Well, that's what you get when developers do documentation...

    For instance, this hardly explains what cURL is, its purpose for existing, or why I should read more...

    Introduction

    PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.
    Blah!!!

    That is why I posted here, because you guys do a much better job of speaking English than a lot of stuff on PHP.net!!

    Thanks,


    Debbie

  7. #7
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DoubleDee View Post
    So how would you submit a payment form normally if cURL didn't exist?

    Is it better than using the browser to do that?
    Hang on let me double check I've got this right. You are submitting payment details from a script on your website to a payment processor yes? - OR are you trying to process a form that is on your website being submitted to your script?

    The impression you initially gave suggested that you were trying to communicate from your script to another website. If thats what you're doing then yes cURL is for you. It will let your script act like a browser and make a request to an external server. The reason I'm now asking is because you're now asking about submitting a form. You then asked is it better than using a browser.. using a browser requires a person to click the send button so now I'm not sure quite what you're trying to do. As I say initially it sounded like you were trying to run an automated server side request to another system but now you're asking about using a browser I'm not sure what you're really trying to do.

    If cURL didn't exist then there would no doubt be some other library of code someone else has come up with somewhere which would do the same job. I'm sure if you hit google you'll find plenty of other versions but none of which will have the the flexibility of cURL. You only need to use google to find examples of how to use it.

    The php manual is pretty clear but it assumes you have a technical understanding of how the internet works, what various protocols are and how to use them etc. If you're not technically minded or you're new to the php programming field then it will sound a lot like jargon. It's one of those things.. the more you use it the clearer it becomes.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  8. #8
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,529
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tangoforce View Post
    Hang on let me double check I've got this right. You are submitting payment details from a script on your website to a payment processor yes? - OR are you trying to process a form that is on your website being submitted to your script?
    I am stressing out over which payment gateway to use and trying to figure things out.

    I would be taking a simple "payment form" and submitting Name, Billing Address, and Credit Card details to some Payment Gateway to have them process the payment.

    On example I saw - I think Authorize.net - used cURL, and so I was like, "Hmmm... wonder what that is and why they are using and the other Payment gateway isn't?!"



    The impression you initially gave suggested that you were trying to communicate from your script to another website.
    Correct, I will be submitting a Payment Form from my website to the Payment Gateway's server.


    If thats what you're doing then yes cURL is for you. It will let your script act like a browser and make a request to an external server. The reason I'm now asking is because you're now asking about submitting a form. You then asked is it better than using a browser.. using a browser requires a person to click the send button so now I'm not sure quite what you're trying to do.
    Let's say I have a simple HTML Form that gathers Name, Billing Address, and Credit Card Info. (The page would technically be a PHP page.)

    The enters their payment info, hits a "Next" button, my PHP redisplays what they just entered and asks them to confirm everything, and then they hit a final "Place Order" button.

    From there, my HTML Form on my PHP Page would submit that information to the Payment gateway's server for processing.

    I guess I don't know how you submit forms. From the books I've read, they always seemed to just use some PHP, but maybe that is because they were submitting the page to themselves and not outside.

    I am a total newbie on this, so pardon any dumb questions!!


    As I say initially it sounded like you were trying to run an automated server side request to another system but now you're asking about using a browser I'm not sure what you're really trying to do.
    Hopefully my explanation above answers that.


    The php manual is pretty clear but it assumes you have a technical understanding of how the internet works, what various protocols are and how to use them etc. If you're not technically minded or you're new to the php programming field then it will sound a lot like jargon. It's one of those things.. the more you use it the clearer it becomes.
    I just remember POST and GET, but that was when I studied this long ago, and I have obviously forgotten a lot of what I studied, PLUS you know how academic most PHP books are!!

    Thanks,



    Debbie

  9. #9
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep you need cURL then to open a connection FROM your server to the payment processor.

    Authorize.net might show you a curl sample and others might not. Thats just how each developer does things. cURL will do exactly what you want.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  10. #10
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,529
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tangoforce View Post
    Yep you need cURL then to open a connection FROM your server to the payment processor.

    Authorize.net might show you a curl sample and others might not. Thats just how each developer does things. cURL will do exactly what you want.
    So if I wanted to submit my form data to the Payment Gateway using cURL, then they shouldn't care, right?

    In other words, *how* I send them data is immaterial to their server as long as I send the correct data in the correct format, right?

    Thanks,


    Debbie

  11. #11
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Correct. At their end it will just like any other http connection that a browser would make. The only difference will be the header which will show that its php making the connection not internet explorer, mozilla etc. As long as they have an api then this shouldn't be a problem unlike some websites which restrict what browsers they will support (EG my bank refuses to let me logon using seamonkey but I can use cometbird which is a IE clone). APIs are different because they're not really dependant on the users browser being secure or the display being correct. They're just providing a way for you to interact with their system and exchange data which is much simpler.

    A word to the wise though, not using cURL is doable but its not ideal since you'll have to do a lot of testing to ensure the code you use can do what you want. I've only ever found one function that does a half decent job and it has a lot less features than cURL and still returns errors sometimes.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  12. #12
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,529
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Okay, Tango, thanks for the information.


    Debbie

    P.S. Know anything about working with Payment Gateways?

  13. #13
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No not really but I've never needed to.

    If you get stuck, download Teamviewer and PM me. I'll hop over to your desktop and take a look with you. Not today though.. it's 1am and I'm about to hit the sack..

    EDIT: I just noticed your post count and mine are reverse... You have 614 and I have 416
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  14. #14
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,529
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tangoforce View Post
    No not really but I've never needed to.

    If you get stuck, download Teamviewer and PM me. I'll hop over to your desktop and take a look with you.
    Well, there are some places that no men are allowed to go... And my desktop is one of them!!


    Not today though.. it's 1am and I'm about to hit the sack..
    Where is it 1:00am now?!


    EDIT: I just noticed your post count and mine are reverse... You have 614 and I have 416
    It is a sign from Heaven that we are soul mates and that you have been sent to help your long lost twin out!!



    Debbie

  15. #15
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lol, no worries but the offer is still there if you need it. Note though that I don't want to be exposed to your authorize.net login or security details etc so if you do take me up on the offer of a desktop session please setup a test account which they offer free. That way your authorize.net account is still secure.

    United Kingdom.. although with the way Scotland, Northern Ireland and Wales are being given their own independence it's more like the Disunited Kingdom these days. Centuries ago the last time this happened it led to civil war.

    Programming soul mates maybe but I already have my love soulmate - she even puts up with me staying up late
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  16. #16
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,529
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tangoforce View Post
    Lol, no worries but the offer is still there if you need it. Note though that I don't want to be exposed to your authorize.net login or security details etc so if you do take me up on the offer of a desktop session please setup a test account which they offer free. That way your authorize.net account is still secure.
    Thanks for the offer, but that is one place I won't go for security reasons. (Way too much - like my Swiss Bank Account # - on my laptop!!


    United Kingdom.. although with the way Scotland, Northern Ireland and Wales are being given their own independence it's more like the Disunited Kingdom these days. Centuries ago the last time this happened it led to civil war.
    Ha ha

    Aren't you guys on Daylight Savings Time?

    Seems like it should be later there?!



    Programming soul mates maybe but I already have my love soulmate - she even puts up with me staying up late
    Good find!

    Well, I'm a SitePoint regular, so say "Hi" when you're around!

    I definitely will need some PHP help!

    Thanks,


    Debbie

  17. #17
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No worries. In honesty it's probably best like that but you asked if I knew anything about payment gateways so I thought I'd offer just in case as you're also taking on cURL.

    Yes we're on DST I think.. I've always been a bit confused by DST. I always thought it meant Dual Summer Time but others refer to it as Daylight Saving Time.. despite the fact we apparently use Daylight saving to ensure we have enough light in the mornings during winter when we're GMT +0. Every year the clocks go forward and then back and every year we hear the same arguements about whether we need to do it or not and how it will affect the scottish.. give them their own time zone and be done with it

    I only hang around in the PHP section of sitepoint. I like to help other people who have obstacles they need help with. I've spent days solving some problems when I was learning that I can now help others to solve in minutes to save them the frustration I suffered. I also have a motivational problem - I find it hard to work on my own code yet easy to work on other peoples. Strange I know but I think the problem is with my own sites they're never finished as I'm always thinking of new features faster than I can code them. Eventually it kinda gets you down and you feel beaten by it. Helping other people with php keeps my mind active with php if that makes any sense..
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  18. #18
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,529
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tangoforce View Post
    I only hang around in the PHP section of sitepoint. I like to help other people who have obstacles they need help with. I've spent days solving some problems when I was learning that I can now help others to solve in minutes to save them the frustration I suffered. I also have a motivational problem - I find it hard to work on my own code yet easy to work on other peoples. Strange I know but I think the problem is with my own sites they're never finished as I'm always thinking of new features faster than I can code them. Eventually it kinda gets you down and you feel beaten by it. Helping other people with php keeps my mind active with php if that makes any sense..
    Well, I believe in giving back to my community as well, so for those who feel unmotivated unless they help me, I say, "Why not?! Let them help Debbie!"

    Seriously, I am under the gun to get some things done, so anyone who can help educate me on PHP (or other topics) is welcome!

    If I ever get *my* website done, then maybe I can spend more time studying books and get to where I am rich and famous and have time to st around and help others too. (We can dream, can't we?!)

    Thanks,


    Debbie

  19. #19
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,529
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Can I use cURL to send an XML-string-thingy?

    Do you use cURL to read information from another server as well?



    Debbie

  20. #20
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for the delay.. had to fit some sleep in

    Theoretically yes but I've never used XML in php as I'v never had the need. I'm sure now I've said that I'll regret it soon..

    cURL does exactly what a browser does. It makes calls to a http webserver like it is a browser so anything the server outputs will be read by cURL whether the server outputs XML, CSV, or just lines of data seperated by the newline character cURL will read it.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  21. #21
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    authorize.net is a very good gateway. They also have their own forum that is quite helpful. They have numerous ways to communicate with their servers. One is called Server Integration Method (SIM), I was able to write code to make test payments in about 5 minutes. I did not to use cURL at all.
    Ryan B | My Blog | Twitter

  22. #22
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,529
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rguy84 View Post
    authorize.net is a very good gateway. They also have their own forum that is quite helpful. They have numerous ways to communicate with their servers. One is called Server Integration Method (SIM), I was able to write code to make test payments in about 5 minutes. I did not to use cURL at all.
    Yeah, I think they are good too. Like I said, it really comes down to if I can because of the bank and payment processor I am using. (Also if there is a penalty for not doing it all through Elavon?!)

    Wow! If you did SIM in 5 minutes then we should talk more! *LOL*

    In a way, it might be a hidden blessing to have to use Internet Secure. It will force me to learn XML which I have put off for years.

    Keep an eye out for my other posts, as I definitely have some XML/PHP related questions!!


    Debbie

  23. #23
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DoubleDee View Post
    It will force me to learn XML which I have put off for years.
    I know that feeling.. On my delayed list I have: Photoshop, CSS, Javascript, advanced mysql, c# etc etc. Oddly I'm ok with HTML which seems pointless these days considering that CSS pretty much does everything instead

    Don't get me started on HTML5, XML, DHTML..

    EDIT: Did I forget to mention Flash and ActionScript?
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  24. #24
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've written code to process transactions through Authorize.net, PayPal, Virtual Merchant, and GoEMerchant - I used curl on all of them, and they all work pretty much exactly the same way: you assign a bunch of POST variables, use curl to do the post request, and receive a response back. It's a little scary the first time you do it but it becomes second nature quickly (Much easier than connecting to UPS/Fedex to get shipping quotes).
    aaron-fisher.com - PHP articles and more

  25. #25
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DoubleDee View Post
    Yeah, I think they are good too. Like I said, it really comes down to if I can because of the bank and payment processor I am using. (Also if there is a penalty for not doing it all through Elavon?!)

    Wow! If you did SIM in 5 minutes then we should talk more! *LOL*

    In a way, it might be a hidden blessing to have to use Internet Secure. It will force me to learn XML which I have put off for years.

    Keep an eye out for my other posts, as I definitely have some XML/PHP related questions!!


    Debbie
    I only have experience with auth.net, so I am not sure what Elavon is. You are charged some with auth.net, I forget the specifics, but there is a charge because they and other gateways pay out the ear to being able to tap/talk to the major credit card companies.
    Ryan B | My Blog | Twitter


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •