Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
Curl and curling from PHP

The Curl library collects a resource in a non-interactive way from a service... libcurl is a free and easy-to-use client-side URL transfer library, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos), file transfer resume, http proxy tunnelling and more! says libcurl's home page. Bindings are currently offered to use the library within your program in Ada95 Basic C C++ Ch Cocoa D Dylan Eiffel Euphoria Falcon Ferite Gambas glib/GTK+ Guile Haskell ILE/RPG Java Lisp Lua Mono .NET Object-Pascal OCaml Pascal Perl PHP Postgres Python R Rexx Ruby Scheme S-Lang Smalltalk SP-Forth SPL Tcl Visual Basic Visual FoxPro Q wxWidgets and XBLite. There's a command line tool in Unix and Linux too with a hst of options - see [here] for examples of it in use.

On today's PHP course, we were accessing my service described in another recent article from another server layer, and we chose to use Curl. PHP needs to be built with the library included - To use PHP's cURL support you must also compile PHP --with-curl[=DIR] where DIR is the location of the directory containing the lib and include directories. In the include directory there should be a folder named curl which should contain the easy.h and curl.h files. There should be a file named libcurl.a located in the lib directory. and the you can use the curl functions in your script:

  $st = curl_init();
  curl_setopt($st,CURLOPT_URL,"http://192.168.192.1/service.php?type=html");
  curl_setopt($st,CURLOPT_RETURNTRANSFER,1);
  // curl_setopt($st,CURLOPT_PROXY,"www-cache.reith.bbc.co.uk:80");
  $data = curl_exec($st);
  curl_close($st);


As with the command line Curl, there are dozens of settings you can specify with cure_setopt... you'll see a few above, and may also like to note CURLOPT_USERAGENT to set the browser identity string and CURLOPT_REFERER to indicate a previous page. Have a look at the PHP manual for the page for much more information!
(written 2013-04-04, updated 2013-04-13)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
H313 - PHP - Page Application and Service Layer
  [4055] Using web services to access you data - JSON and RESTful services - (2013-03-29)
  [4053] Frameworks - learning through exploring and understanding data sources - (2013-03-27)


Back to
The highs and lows of customer service - Cheltenham
Previous and next
or
Horse's mouth home
Forward to
CodeIgniter - an excellent PHP framework with an easy start point
Some other Articles
Backups by crossover between network centres - setting up automatic scp transfers
Sessions, forms and validation in CodeIgniter - early examples
Seamless, integrated IT - we have a long way to go!
CodeIgniter - an excellent PHP framework with an easy start point
Curl and curling from PHP
The highs and lows of customer service - Cheltenham
stdClass in PHP - using an object rather than an associative array
An overpractical test of our backup strategy!
On Salford Docks - mind over matter?
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4059_Cur ... m-PHP.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat