WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Open remote https url using Curl and accept cookie
Categories : PHP, CURL Click here to Update Your Picture
Ben Yacoub Hatem
Date : Apr 19th 2005
Grade : 3 of 5 (graded 6 times)
Viewed : 64450
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Ben Yacoub Hatem
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Some websites force cookie usage to open a https page, So i've written this function to make it easier. To use it just create a cookie.txt file and allow write permission.

<?php

/**
* Open an url on https using curl and return content
*
* @author hatem <info@phptunisie.net>
* @param string url            The url to open
* @param string refer        Referer (optional)
* @param mixed usecookie    If true, cookie.txt    will be used as default, or the usecookie value.
* @return string
*/
function open_https_url($url,$refer = "",$usecookie = false) {

    if (
$usecookie) {
       
        if (
file_exists($usecookie)) {
       
            if (!
is_writable($usecookie)) {
               
                return
"Can't write to $usecookie cookie file, change file permission to 777 or remove read only for windows.";
            }
        } else {
           
$usecookie = "cookie.txt";
            if (!
is_writable($usecookie)) {
               
                return
"Can't write to $usecookie cookie file, change file permission to 777 or remove read only for windows.";
            }
        }
   
    }

   
$ch = curl_init();
   
   
curl_setopt($ch, CURLOPT_URL, $url);
   
   
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   
   
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
   
   
curl_setopt($ch, CURLOPT_HEADER, 1);
   
   
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
   
    if (
$usecookie) {
       
curl_setopt($ch, CURLOPT_COOKIEJAR, $usecookie);
       
       
curl_setopt($ch, CURLOPT_COOKIEFILE, $usecookie);   
    }
   
    if (
$refer != "") {
   
       
curl_setopt($ch, CURLOPT_REFERER, $refer );
       
    }
   
   
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
   
   
$result =curl_exec ($ch);
   
   
curl_close ($ch);
   
   return
$result;
}
?>


Usage:
<?php
echo  open_https_url("https://domain.com/","",true);
?>



These PHP Classes Check if a host is alive using various methods.
Categories : PHP, PHP Classes, Sockets, CURL
Import the yahoo address book.
Categories : PHP, CURL, Authentication
Using cURL to download a file programmatically.
Categories : PHP, PHP Extensions, CURL
Link Manager for Link Exchangers
Categories : PHP, PHP Classes, Databases, MySQL, CURL
Url To Pdf Report By Remote Application
Categories : PHP, PHP Classes, PDF, CURL
Sample AIM (Advanced Integration Method) PHP Script For Authorize.net using CURL
Categories : CURL, Ecommerce, PHP
Amazon.com API, CURL-REST Parser. Obtain data about Amazon products (PHP5 +)
Categories : PHP, Ecommerce, XML, Web Services, CURL
Yahoo! Messenger Friend List
Categories : PHP, CURL, HTML and PHP
Using data from a string.
Categories : PHP, Strings, CURL
PHP Youtube Downloader - This is a set of PHP functions that can be used to download movies from Youtube.com.
Categories : PHP, CURL, Regexps
curl_close -- Close a CURL session
Categories : PHP, PHP Functions, CURL
Newbie Notes #8 - A cron trick
Categories : PHP, CURL, Beginner Guides
Verifying / Correcting Addresses Grabbed From The YellowPages Example
Categories : PHP, CURL
Returns Yahoo! Address Book and Messenger List as an Array
Categories : PHP, PHP Classes, CURL
A function to check if a URL exists
Categories : PHP, CURL, HTTP
 kailash agrawal wrote :1698
I use this code exactly as shown on this url.
$url="https://secure.jetairways.com/jetobe/onlinebooking.aspx?";
cookie.txt file is created with 0 bytes.
However, the website just hangs after that. No data is returned back. Nothing happens.
I tried it 1 other https website, and the same thing happens. If I use these url on a browser, they work just fine. I would appreciate, if you help me find out what`s missing. I`ve tried many forums with no success.