Solved

PHP - Getting hidden post variable from external page.

Posted on 2004-09-03
2
2,706 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…
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.

730 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