Solved

PHP - Getting hidden post variable from external page.

Posted on 2004-09-03
2
2,700 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Selecting SUM data from mysql table with PHP 4 20
Blocking submission of a web-based form 6 21
UPDATE query not working in mysqli php 8 52
How would I do this...? 2 28
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…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

803 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