Skip to content
WJunction - Webmaster Forum

Adfocus doesn't return anything in cURL

Status
Not open for further replies.
i am not getting any output from adfocus link using curl :'(

Code:
<?php
$ch = curl_init ("http://adfoc.us/426491");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_REFERER, "http://adfoc.us/*********1");
$page = curl_exec ($ch);
echo $page;
?>

i just need to echo the whole source code of url
 

7 comments

The reason why it doesn't work is because they require useragent and accept property in the header to be sent, maybe to prevent from bots.

Adding useragent and accept property works:
PHP:
<?php
$ch = curl_init ("http://adfoc.us/426491");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_REFERER, "http://adfoc.us/*********1");
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0');
curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'));
$page = curl_exec ($ch);
echo $page;
?>

You can use a textbox or encode html tags before printing to remove browser rendering:
PHP:
<?php
$ch = curl_init ("http://adfoc.us/426491");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_REFERER, "http://adfoc.us/*********1");
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0');
curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'));
$page = curl_exec ($ch);
echo '<textarea style="width:100%; height: 100%;">' . $page . '</textarea>';
?>
 
i don't say adfocus is best nowdays not even adfly !
i have jumped from them and using a new and stable one :D
and paying on time every week without fail
 
Thanks soft :)
so we need to analyse the header in source code too, i thought they check for referrer only

Offtopic:
(i saw the header using live http headers)
so mate we need to add the things in " Accept: xxxxxxxxx " as HTTPHEADER?
curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'));

is it applicable for all sites mate....??
http://www.wjunction.com/member.php?u=12795
 
Accept Header tells what type of response the browser is looking for.
So for this: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Expanded, asks for any of the following formats:
- (X)HTML format (HTML First)
- XML format
- Finally */* means for any type of format.

So it should be applicable for all sites
 
Last edited:
once again thanks buddy, now i understood :)

----

Hi spartan, there is a lot of ways to monatizing sites, but these adfly/adfocus/linkbucks are worst than popup, just my opinion ;)

Note:
now i am learning php, daily 30 minutes - 1 hour, sometime 2 hour in holiday :)
 
Last edited:
Status
Not open for further replies.

About the author

T
Active Member · Joined
Helping Others
1,559
Messages
309
Reactions
83
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom