Using cURL (in PHP) to access http s url is often not as simple as using the proper url.�ϥα����]�bPHP �^�ӳX�ݪ�HTTP s���}�������O����²��A�ϥΥ��T�����}�C Using it for authentication is also not very clearly documented.�Υ��i�����ҡA�]�S���ܲM�����O��C This is a mini tutorial for both accessing https url's as well as for http authentication.�o�O�@�Ӥp���е{���q�Lhttps�X�ݺ��}���A�H�ά�HTTP�{�ҡC

The following is a simple example which show the most common options you will ever need to use to access https url's as well as for http authentication.�H�U�O�@��²�檺�Ҥl��ܡA�̱`������ܡA�z�N�H������ɭԳ��ݭn�ϥΦs��q�Lhttps URL���A�H�ά�HTTP�{�ҡC

// The usual - init a curl session and set the url / /�D�`-i nit���@�����|ij�A�ó]�m���}
$ch = curl_init();��CH = curl_init �] �^ ;
curl_setopt($ch, CURLOPT_URL, $base_url); curl_setopt �]�����Ϸ|��A curlopt_url �A��base_url �^ ;

// Set your login and password for authentication / /�]�m�z���n��W�M�K�X����
curl_setopt($ch, CURLOPT_USERPWD, 'login:pasword'); curl_setopt �]�����Ϸ|��A curlopt_userpwd �A '�n��G pasword ' �^ ;

// You can use CURLAUTH_BASIC, CURLAUTH_DIGEST, CURLAUTH_GSSNEGOTIATE, / /�z�i�H�ϥ�curlauth_basic �A curlauth_digest �A curlauth_gssnegotiate �A
// CURLAUTH_NTLM, CURLAUTH_ANY, and CURLAUTH_ANYSAFE / / curlauth_ntlm �A curlauth_any �A curlauth_anysafe
// / /
// You can use the bitwise | (or) operator to combine more than one method. / /�z�i�H�ϥΦ�B���| �]�Ρ^�g��̵��X�_�ӡA����@�ؤ�k�C
// If you do this, CURL will poll the server to see what methods it supports and pick the best one. / /�p�G�A�o�˰��A�����A�N�լd�A�Ⱦ��A�ݬݦ������k�A�����M�D��䤤�̦n���@�ӡC
// / /
// CURLAUTH_ANY is an alias for CURLAUTH_BASIC | CURLAUTH_DIGEST | / / curlauth_any�O�@�ӧO�W��curlauth_basic | curlauth_digest |
// CURLAUTH_GSSNEGOTIATE | CURLAUTH_NTLM / / curlauth_gssnegotiate | curlauth_ntlm
// / /
// CURLAUTH_ANYSAFE is an alias for CURLAUTH_DIGEST | CURLAUTH_GSSNEGOTIATE | / / curlauth_anysafe�O�@�ӧO�W��curlauth_digest | curlauth_gssnegotiate |
// CURLAUTH_NTLM / / curlauth_ntlm
// / /
// Personally I prefer CURLAUTH_ANY as it covers all bases / /�ڭӤH���wcurlauth_any �A�]�����[�\�Ҧ���a
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt �]�����Ϸ|��A curlopt_httpauth �A curlauth_any �^ ;

// This is occassionally required to stop CURL from verifying the peer's certificate. / /�o�O�����|�n�D������q�ֹ�P�������ҡC
// CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE if / / curlopt_ssl_verifyhost�i���ٻݭn�o��u�ΰ��A�p�G
// CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2 - check the existence of a / / curlopt_ssl_verifypeer�Q�T�Ρ]�q�{�Ȭ�2 -�ˬd�s�b�@��
// common name and also verify that it matches the hostname provided) / /�q�ΦW�١A�]���ҥ��O�_�ŦX�Ҵ��Ѫ��D���W�^
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt �]�����Ϸ|��A curlopt_ssl_verifypeer �A�갲�^ ;

// Optional: Return the result instead of printing it / /�i��G��^�����G�A�Ӥ��O�����L��
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt �]�����Ϸ|��A curlopt_returntransfer �A 1 �^ ;

// The usual - get the data and close the session / /�D�`-���ƾڨ������|ij
$data = curl_exec($ch);���ƾ�= curl_exec �]��CH �^ ;
curl_close($ch); curl_close �]��CH �^ ;

Use the above as a template for your code to simplify your data access using cURL.�ϥΤW�z�@���d���A���z���N�X�H²�Ʊz���ƾڦs��ϥα����C

PS.�O�w���`�����Ѫ�C The challenge with cURL documentation in PHP is that it is hard to find what you need from hundreds of available options and without enough examples of common use cases.�D�ԻP���������bPHP�O�A�o�O������z�һݭn���q�Ʀʭӥi�ѿ�ܡA�èS���������Ҥl�A�@�P�ϥΪ��ץ�C What is needed is a series of How-To's like the mini-tutorial above.�һݭn���O�@�t�C���p��쪺�@�ˡA�p�ɲߥH�W�C