For 2023 (and 2024 ...) - we are now fully retired from IT training. We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.
Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!
I am also active in many other area and still look after a lot of web sites - you can find an index ((here)) |
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 [4053] Frameworks - learning through exploring and understanding data sources - (2013-03-27) [4055] Using web services to access you data - JSON and RESTful services - (2013-03-29)
Some other Articles
Backups by crossover between network centres - setting up automatic scp transfersSessions, forms and validation in CodeIgniter - early examplesSeamless, integrated IT - we have a long way to go!CodeIgniter - an excellent PHP framework with an easy start pointCurl and curling from PHPThe highs and lows of customer service - CheltenhamstdClass in PHP - using an object rather than an associative arrayAn 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).
|
|