...

View Full Version : url help please, unusual request :)



LJackson
03-22-2010, 12:38 AM
Hi All,

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

which when clicked takes you to this url
http://www.play.com/DVD/DVD/4-/-/-/Product.html?title=10674623&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

LJackson
03-22-2010, 01:29 AM
ok my code seems to automatically get the linked url and the data i need from it.

so all seems solved :D

thanks
Luke

LJackson
03-22-2010, 02:46 AM
ok i have this static code as a test


$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

$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

http://www.awin1.com/pclick.php?p=48150464&a=79524&m=1418&platform=cs

the same as

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

MattF
03-22-2010, 04:05 AM
$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?

LJackson
03-22-2010, 11:10 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum