Solved

PHP - Getting hidden post variable from external page.

Posted on 2004-09-03
2
2,696 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
ID: 11979209
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
ID: 11981297
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

895 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