Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts

    Exclamation url help please, unusual request :)

    Hi All,

    i am pulling out a url from an api which would look something like this
    http://www.awin1.com/pclick.php?p=48...18&platform=cs

    which when clicked takes you to this url
    http://www.play.com/DVD/DVD/4-/-/-/P...23&source=9593

    i have some code which will get the title number in the second url which is good the trouble is i can only pull out the first url from the api so i never see the second url.

    is there a way to somehow get the page url that the first url links to?

    cheers
    Luke
    Last edited by LJackson; 03-22-2010 at 12:44 AM.

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts
    ok my code seems to automatically get the linked url and the data i need from it.

    so all seems solved

    thanks
    Luke

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts
    ok i have this static code as a test

    Code:
    $uri = 'http://www.awin1.com/pclick.php?p=48150464&a=79524&m=1418&platform=cs';
    $input = file_get_contents($uri);
    						if (preg_match('#/Films/(\w+?)\.flv\&#', $input, $match))
    						{?>
    							<img id="listen<?php echo $counter?>" src="images/listen.png" border="0" alt="Preview Tracks" title="Preview Songs" style="visibility:hidden" onmouseover="this.style.cursor='pointer';" onclick="window.open('song_preview.php?id=<?php echo $row['ASIN']?>','Window1','menubar=no,width=356,height=300,toolbar=no,resize=no');" />
                        <script>document.getElementById("listen<?php echo $counter?>").style.visibility="visible";</script>
                      <?php }
    and it displays the image fine which is expected.

    i then have this code on my main page
    PHP Code:
                            $url = $link;
                            $input = file_get_contents($uri);

                            if (preg_match('#/Films/(\w+?)\.flv\&#', $input, $match))
                            {?>
                                <img id="listen<?php echo $counter?>" src="images/listen.png" border="0" alt="Preview Tracks" title="Preview Songs" style="visibility:hidden" onmouseover="this.style.cursor='pointer';" onclick="window.open('song_preview.php?id=<?php echo $row['ASIN']?>','Window1','menubar=no,width=356,height=300,toolbar=no,resize=no');" />
                        <script>document.getElementById("listen<?php echo $counter?>").style.visibility="visible";</script>
                      <?php }
    $link is db row which has the same url as the test does but the &'s are &amp;'s and the image wont show, i have tried using htmlspecialchars_decode and html_entity_decode on the $link which seems to replace the &amp; with a & so looking like the url is exactly the same as in the test code but it still refuses to work but im not sure why?

    is
    Code:
    http://www.awin1.com/pclick.php?p=48150464&a=79524&m=1418&platform=cs
    the same as
    Code:
    htmlspecialchars_decode('http://www.awin1.com/pclick.php?p=48150464&amp;a=79524&amp;m=1418&amp;platform=cs');
    ??? if not how do i make it the same value?

    thanks
    Luke

  • #4
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Code:
    $url = $link;
    $input = file_get_contents($uri);
    uri is not url. Would it not have been better to keep this question in the original thread, btw?

  • Users who have thanked MattF for this post:

    LJackson (03-22-2010)

  • #5
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts
    Hi mate,

    i thought it best to start a new thread because it was a different problem, even thought it relates to the same code. in heinsite your probably right,but it seemed the right thing to do at the time

    man i need to get my eyes tested lol
    thanks mate


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •