It gets easier with repetition. 5/23 Web Dev Weekly Hed: Working with cURL Dek: It gets easier with repetition By Garth Gillespie
Many Web sites choose to expand their offerings via partnerships, and many B2B service operations have established significant databases that can be integrated into an existing Web site for this purpose. The resultant offering will be hosted either on your local site or your B2B partner’s site. When hosted on your partner’s site, (called a cobrand), typically you provide a design template of your site so that the cobrand will still have the look and feel of your site.
There are many reasons why it is preferable for these service partners to want to host their own services; the foremost is security. Yet, there are also many reasons why a Web site would not be comfortable having templates hither and yon; the foremost is maintenance. The compromise that sometimes results is a framed page wherein each respective party serves a piece of the page, resulting in an overall horrible appearance.
But what if you could dynamically integrate your partner’s piece of the frame into your site’s template on your own server? Most scripting languages allow for some way of grabbing URLs (HTTP GET), but most don’t have an easy way to post form data as is usually needed when dealing with database queries.
For this, let me recommend cURL. Currently on version 7.7.3, cURL comes in two flavors, a standalone executable or a set of libraries that can be integrated into Java, PHP, Perl, Ruby, or tcl. cURL’s homepage states:
Curl is a tool for transferring files with URL syntax, supporting FTP, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE, and LDAP. Curl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, kerberos, HTTP form-based upload, proxies, cookies, user+password authentication, file transfer resume, http proxy tunneling and a busload of other useful tricks.
Obviously, you can do more than merely POST data to another server and collect the responses. You are limited only by your imagination. I learn new things to do with cURL every time I use it. Check it out! It’s another handy developer’s tool that I have come to enjoy using.
Do you have a useful tool or library that you have found helpful in your work? Let me know at [email protected]
Garth Gillespie is architect and chief technologist for ComputerUser.com.