PHP script that displays another page partial content

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • diego.sala@gmail.com

    PHP script that displays another page partial content

    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?

  • Rik

    #2
    Re: PHP script that displays another page partial content

    diego.sala@gmai l.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('|<d iv
    id="phoneUpdate QueryResults">. *?<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 =
    'T4256046810116 7294708450l10n= %2Fncom4%2FGB%2 FSoftwareVersio n%2F%2Flabels.s
    tr%3B%2Fncom4%2 FGB%2FSoftwareV ersion%2F%2Ferr ors.str%3B%3B%3 B&T4256046810 11
    67294708450%7Ba ctionForm.produ ctCode%7D='.$id ;
    $url =
    'http://europe.nokia.co m/appmanager/UnitedStatesEng lishEUROPE_NOKI A_COM_3/G
    et_support?_nfp b=true&_windowL abel=T425604681 01167294708450& _pageLabel=P324
    575&wsrp-urlType=blockin gAction&wsrp-interactionStat e=_action%3D%2F pageflow
    s%2FSoftwareVer sion%2FgetVersi on';

    $ch = curl_init();
    curl_setopt($ch , CURLOPT_URL, $url);
    curl_setopt($ch , CURLOPT_POST, true);
    curl_setopt($ch ,CURLOPT_POSTFI ELDS,$post);
    curl_setopt($ch , CURLOPT_RETURNT RANSFER, true);

    $html = curl_exec($ch);
    preg_match('|<d iv
    id="phoneUpdate QueryResults">. *?<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



    Comment

    • lucavilla@cashette.com

      #3
      Re: PHP script that displays another page partial content

      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:


      Any idea about what's the problem?

      Comment

      • Rik

        #4
        Re: PHP script that displays another page partial content

        lucavilla@cashe tte.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


        Comment

        • diego.sala@gmail.com

          #5
          Re: PHP script that displays another page partial content

          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?

          Comment

          Working...