The time now is 09/06/08 - 21:54
Log in: Username: Password:
Search forums for:
  

PHP question

Post new topic   Reply to topic
Author Message
kireol
RealPoor Master of Posts
RealPoor Master of Posts


Joined: 02 Aug 2003
Posts: 9517
Location: Royal Oak, MI



PostPosted: 12/17/05 - 02:28    Post subject: PHP question Reply with quote

I'm trying to use the USPS zip code finder. You give it an address, it gives you the zip code. It works fine in firefox. So I was trying to use PHPs curl to send the form variables. In FireFox I checked the form variables values and made sure I had them all. There are some I didnt put in because those had null values.

Why does this work fine in a real browser but not in PHP?

Will give oral if you can hepl!!!!!


Code:
<?PHP
        $cookie_file_path = "cookies/cookiejar.txt"; // Please set your Cookie File path
        $fp = fopen("$cookie_file_path","w") or die("<BR><B>Unable to open cookie file $mycookiefile for write!<BR>");
        fclose($fp);

        //load form page.
        $ch = curl_init();
        $url = "http://zip4.usps.com/zip4/welcome.jsp";
        curl_setopt($ch, CURLOPT_URL, $url);
        $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
        curl_setopt($ch, CURLOPT_USERAGENT, $agent);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
        $result = curl_exec ($ch);
        print $result;

        //load page result page.

        $url = "http://zip4.usps.com/zip4/zcl_0_results.jsp";
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, 1);
        $mypostfields = urlencode("visited=1&pagenumber=0&address2=1500 PENNSYLVANIA AVE&city=WASHINGTON&state=DC");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $mypostfields);
        $result = curl_exec ($ch);

        print $result;

        curl_close($ch);
?>
Back to top
Spiritz
RealPoor Sensei
RealPoor Sensei


Joined: 11 Oct 2002
Posts: 1969
Location: Huntington Beach, CA



PostPosted: 12/17/05 - 02:31    Post subject: Reply with quote

Stop using PHP, problem solved.
Back to top
motherface
RealPoor Guru
RealPoor Guru


Joined: 12 Mar 2003
Posts: 3407



PostPosted: 12/17/05 - 03:03    Post subject: Reply with quote

Why not just do a GET:

http://zip4.usps.com/zip4/zcl_0_results.jsp?visited=1&pagenumber=0&firmname=&address2=1600+PENNSYLVANIA+AVE&address1=&city=WASHINGTON&state=DC&urbanization=&zip5=&submit.x=28&submit.y=8&submit=Find+ZIP+Code
Back to top
kireol
RealPoor Master of Posts
RealPoor Master of Posts


Joined: 02 Aug 2003
Posts: 9517
Location: Royal Oak, MI



PostPosted: 12/17/05 - 03:08    Post subject: Reply with quote

motherface wrote:
Why not just do a GET:

http://zip4.usps.com/zip4/zcl_0_results.jsp?visited=1&pagenumber=0&firmname=&address2=1600+PENNSYLVANIA+AVE&address1=&city=WASHINGTON&state=DC&urbanization=&zip5=&submit.x=28&submit.y=8&submit=Find+ZIP+Code


my god you are seksee!
Back to top
Display posts from previous:   
Post new topic   Reply to topic
Page 1 of 1

Related topics:
One question about LOTRO Raid rules
Rogue AA questions
EverQuest 2 Expansion packs question
Anarchy Online Engineer question
Question about Eve Online TV
Quick question (converting audio from .wmv to a mp3 or wav)
Question about inventory in Guild Wars
Apache / SQL question
LOTRO Economy question
Activating Everquest 2 account question
Anyone in/near Minneapolis? Got a few questions-
Installing Linux Question (GRUB bootloader)
Question regarding Western Union and fraud claims
noob question
EQ in window question
Question about diabetic.
Something About Mary Commercial Question - Name of song help
Random penis piercing question!
Age of Conan Sieges question
question about Venus Flytraps