PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Old June 26th, 2006, 05:09 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,308 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 30
Send HTTP request & parse response

I need to send an HTTP Request to
http://domain.com/Encryptor.aspx?name=family_name_here
and parse the HTTPResponse (which will be an 8 character string).

How do I do this using PHP?

Reply With Quote
Old June 27th, 2006, 12:06 AM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,774 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 15 h 13 m 9 sec
Reputation Power: 12
RE: Send HTTP request & parse response

Hmm - What exactly are you trying to get out of it? A post variable - you can get that with $_POST. A get var would be available through $_GET. What does the API say?

If it is something more complex then that - check these various extensions out. maybe you can find what you need in them. I have placed them in the order I would try to use them (http first, sockets last).

References:
http://www.php.net/curl
http://www.php.net/stream
http://www.php.net/sockets

Reply With Quote
Old June 27th, 2006, 06:27 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,308 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 30
RE: Send HTTP request & parse response

Hi Lig. Here's what I'm trying to accomplish...I have a web form where the user will enter his "family name," address and other information. PHP will take the name that's been entered and access an ASPX script (on a windows server). This ASP(X) script executes a program called Encryptor which takes the "family name" that's entered and generates a random 8 character string (based on the first 8 characters of the family name). The Encryptor program was created in .NET. After the 8 character string is created, it needs to be sent to my autoresponder script (which is PHP). The autoresponder will send the "family name" (as entered on the web form) and the 8-character string. These 2 pieces of data will be used as the login and passcode to access a software program.

My initial post below was what the .NET programmer told me to ask for. The .NET programmer doesn't know PHP and he's looking for the command to send an HTTP request and then parse the 8 character string that's created.

Basically, the problem I'm running into is that the software program is .NET and Encryptor is .NET, yet I'm using PHP to process the "family name" form data. So, I need some way for PHP to "call/send an HTTP Request" to the ASP(X) script, which will take over once it's called. I'm on Linux-based hosting and I don't want to switch the order page/site to Windows-based hosting. I had no idea what I was getting myself into when I agreed to let the programmer create the software program in .NET. I'm not a programmer, and I didn't realize that Microsoft had such a monopoly on development tools and **forced** Windows-based web hosting.

According the the .NET programmer that I'm working with, there will be only three files on the Windows-based webhost... a DLL for the Encryptor, the ASP(X) script that runs the Encryptor, and the .NET framework. My order page and site will remain on Linux hosting.

Hope this makes sense. Any feedback/advice you could provide would be appreciated. Based on Google searches and reading, could I use "file_get_contents" to send the HTTPRequest and then "file_put_contents" to write the string to a file (which will be an autoresponder)?

Reply With Quote
Old June 27th, 2006, 07:53 PM
Insane Insane is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: sacramento, CA, USA
Posts: 80 Insane User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
RE: Send HTTP request & parse response

just have the key printed out to the page with nothing else and open the page in php using almost any file pointer function. ie fopen() file() file_get_contents(). the last one would probably be the easiest and file() the 2nd easiest.

php Code:
Original - php Code
  1.  
  2. $family_name = "SomeFamilyName";
  3. $code = file_get_contents("http://domain.com/Encryptor.aspx?name=".$family_name);
  4.  
  5. echo $code;

Reply With Quote
Old June 27th, 2006, 11:49 PM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,774 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 15 h 13 m 9 sec
Reputation Power: 12
RE: Send HTTP request & parse response

nice way to handle it insane. definately the easier way.

If however you must get the actual headers of the response from the ASPX page, curl has the ability to get the headers with the CURLOPT_HEADER option set in the curl_setopt().

Reply With Quote
Old June 28th, 2006, 02:19 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,308 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 30
RE: Send HTTP request & parse response

Insane - Thank you! Your solution is so simple, and yet it wonderfully solves my problem.

Lig - Can you explain why I might want to get the headers? What do you mean by headers (IP, timestamp)?

Reply With Quote
Old June 28th, 2006, 03:22 AM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,774 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 15 h 13 m 9 sec
Reputation Power: 12
RE: Send HTTP request & parse response

I meant the http headers. That is what I thought you were originally after.

Reply With Quote
Old June 28th, 2006, 02:56 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,308 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 30
RE: Send HTTP request & parse response

Ok. Fortunately, I don't need HTTP headers. Thanks.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Send HTTP request & parse response


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap