28, May 2012

final destination of a link - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: final destination of a link
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: final destination of a link  (Read 1112 times)
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« on: Dec 15, 2006, 09:50:07 pm »

Is it possible to retrieve the destination of a link, when it gets redirected? Many affiliate programs use a 3rd party to pay the affiliates. To track sales the promotion of the product links to the 3rd party website.
For instance: a link would point to www.3rdpartyprocessor.com/productId/myAffiliateId when someone clicks the link they will end up at: www.producthomepage.com
Is there any way I can retrieve the second URL when I only know the first one?


Last blog : Are You Stumbling Yet?
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #1 on: Dec 15, 2006, 10:00:03 pm »

I just found out that a download with cURL will download the content of the second URL. how to download a file with cURL and php
If I look thru the downloaded source I can see from which page it is, but this is because the page I retrieved contains some images coded as: src="http://www.domain.com/images/image.gif"
Surely a lot of pages retrieved will not contain the domain name in the code but just use: /images/image.gif so my problem has not been solved yet...


Last blog : Are You Stumbling Yet?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Dec 16, 2006, 12:04:40 am »

Quote
Surely a lot of pages retrieved will not contain the domain name in the code but just use: /images/image.gif so my problem has not been solved yet...

with curl it's possible to retrieve a complete bunch of headers, check curl_getinfo()

Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #3 on: Dec 16, 2006, 12:18:48 am »

That is exactly what I was looking for!
Code:
curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);

just before the
Code:
curl_close($ch);

shows the URL I'm looking for.

Thanks man!


Last blog : Are You Stumbling Yet?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Dec 16, 2006, 12:25:26 am »

Cheesy

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #5 on: Dec 16, 2006, 12:37:30 am »

This may also be useful :

curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue);?>

It will follow all the Location headers.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #6 on: Dec 16, 2006, 01:19:28 am »

sounds like that could be used as well.


Last blog : Are You Stumbling Yet?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #7 on: Dec 16, 2006, 11:58:13 am »

Yeah, this will follow all the redirections, and then with the curl_info you can check which was the final destination.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=5251
Tags : redirect php Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: final destination of a link
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 07:06:06 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.