Solved

PHP - Getting hidden post variable from external page.

Posted on 2004-09-03
2
2,695 Views
Last Modified: 2013-12-13
Okay, this is a complicated question that requires a really specific answer, so I am going to try to be as specific as possible.

I am trying to make a PHP script that allows my friends to Text message my Cricket wireless cell phone from the internet, but bypasses their prompt page that displays an accept/decline deal.  Now, I do not want anyone telling me to make an email script to text message mynumber@carriersext.com because cricket does not have this service, i promise.

Now here is where my problem comes in,  when someone goes to the cricket text messaging webiste:

http://www.mycricket.com/SendtextMessage.aspx

It generates a HUGE random encoded message, that is required to be submited as a variable to the ASP file in order to send the message.  Now, It works great if i just copy and paste one of those encoded things right from the page, but each code expires after 3 messages are sent.  So, is what I need to do is make a PHP script/function to go and access that page each time the script is ran, and grab that huge encoded variable, and set it to a variable in my PHP script.  I am almost positive this is possible, it just might be pretty complicated, that's why I made it worth so many points..


To find that varaible I am talking about... veiw the source of http://www.mycricket.com/SendtextMessage.aspx and search for the string:

<input type="hidden" name="__VIEWSTATE"




You'll see what I mean.  If you need any clearifications, please don't hesitate to ask.
0
Comment
Question by:evanatmtd
2 Comments
 
LVL 6

Accepted Solution

by:
CosminB earned 500 total points
Comment Utility
try this:
<?php
$contents = file_get_contents('http://www.mycricket.com/SendtextMessage.aspx', false);
$start = strpos($contents, '<input type="hidden" name="__VIEWSTATE" value="') + strlen('<input type="hidden" name="__VIEWSTATE" value="');
$stop = strpos($contents, '"', $start+1);
$text = substr($contents, $start, $stop-$start);
echo $text;
?>

if you don't have PHP > 4.3.0 use
$contents = implode('',file('http://www.mycricket.com/SendtextMessage.aspx'));
insetad of
$contents = file_get_contents('http://www.mycricket.com/SendtextMessage.aspx', false);
0
 

Author Comment

by:evanatmtd
Comment Utility
oh my god i love you! lol, thanks a million, that worked PERFECT.  I have been looking for this for months.  GREAT code.  I give you an A+++++.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now