By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,034 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,034 IT Pros & Developers. It's quick & easy.

PHP script that displays another page partial content

P: n/a
If you go to http://europe.nokia.com/A4305060, fill the "Enter your
product code:" field with the value "0523183" and press "Go" (the
ending page URL varies because there's a variable session-ID in the
URL-link associated to "Go") you will obtain this string:

"Version: RM43_V1.10.030"

Is it possible to have a string.php page that just display this string?
how can I do it?

Jan 13 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Rik
di********@gmail.com wrote:
If you go to http://europe.nokia.com/A4305060, fill the "Enter your
product code:" field with the value "0523183" and press "Go" (the
ending page URL varies because there's a variable session-ID in the
URL-link associated to "Go") you will obtain this string:

"Version: RM43_V1.10.030"

Is it possible to have a string.php page that just display this
string? how can I do it?
It would help if you could determine what actually happens when posting the
form. It relies on javascript, which is not available to you directly in
PHP. If you know a little bit of javascript and have some time, you might
figure out exactly what's done on a submit of the form, and mimique that
with for instance cURL.

If it's directly written to the page, you could use a regex on the obtained
$html to capture the version:

preg_match('|<div
id="phoneUpdateQueryResults">.*?<dd><span>(.*)</span>|si',$html,$match);
echo "Version is {$match[1]}.";

I'd say it is a LOT of work to figure out how to bypass/replicate the
javascript. Maybe it's easier to ask Nokia wether they have some more
direct/transparant link you can use.

I've cheated a bit: I have used Fiddler to examine the request, and I've
taken as much out as i could to still make it work. Using cURL to get the
data seems to work here now, but as I'm not familiar with the Nokia
backend, I cannot be sure about the validity of the different values, they
can be temporary, expiring, are altered without notification offcourse :-).

<?php
$id = '0523183';
$post =
'T42560468101167294708450l10n=%2Fncom4%2FGB%2FSoft wareVersion%2F%2Flabels.s
tr%3B%2Fncom4%2FGB%2FSoftwareVersion%2F%2Ferrors.s tr%3B%3B%3B&T425604681011
67294708450%7BactionForm.productCode%7D='.$id;
$url =
'http://europe.nokia.com/appmanager/UnitedStatesEnglishEUROPE_NOKIA_COM_3/G
et_support?_nfpb=true&_windowLabel=T42560468101167 294708450&_pageLabel=P324
575&wsrp-urlType=blockingAction&wsrp-interactionState=_action%3D%2Fpageflow
s%2FSoftwareVersion%2FgetVersion';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$html = curl_exec($ch);
preg_match('|<div
id="phoneUpdateQueryResults">.*?<dd><span>(.*)</span></dd>|si',$html,$match
);
echo "Version is {$match[1]}.";
?>

Mind you: the $post & $url values should be on one line, remove the
newlines envitabel created in posting to a newsgroup.
--
Rik Wasmus

Jan 13 '07 #2

P: n/a
Rik, thank you very much for your code.
I tried it, after having adjusted the the $post and $url values in one
line, but all I see at the end is "Version is .".

I'm not sure about what the script does but note that the url alone
doesn't work if I try it in Internet Explorer:
http://europe.nokia.com/appmanager/U...n%2FgetVersion

Any idea about what's the problem?

Jan 13 '07 #3

P: n/a
Rik
lu*******@cashette.com wrote:
Rik, thank you very much for your code.
I tried it, after having adjusted the the $post and $url values in one
line, but all I see at the end is "Version is .".

I'm not sure about what the script does but note that the url alone
doesn't work if I try it in Internet Explorer:
http://europe.nokia.com/appmanager/U...n%2FgetVersion
>
Any idea about what's the problem?
The url alone will not work, it's a form post, that's the reason to user
cURL.

Indeed the url has seemed to timed out somehow. I can take the new
poststring and url without a problem en replicate it, but I think it will
just timeout again.

Guess it either has going to be the hard way: determine what the javascript
actually does, ir the better way: contact Nokia with the question if they
have an url available which does not time out, or another service to
automatically retrieve the lastest version.
--
Rik Wasmus
Jan 13 '07 #4

P: n/a
Rik, thank you very much for your code.
I tried it, after having adjusted the the $post and $url values in one
line, but all I see at the end is "Version is .".

I'm not sure about what the script does but note that the url alone
doesn't work if I try it in Internet Explorer:
http://europe.nokia.com/appmanager/U...UROPE_NOKIA_CO...
Any idea about what's the problem?

Jan 13 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.