homepage Welcome to WebmasterWorld Guest from 54.225.24.227
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Google / Google AdSense
Forum Library, Charter, Moderators: incrediBILL & jatar k & martinibuster

Google AdSense Forum

    
AdSense for Mobile Woes
yaashul




msg:4582314
 1:00 pm on Jun 8, 2013 (gmt 0)

Google Mobile ads for PHP based server side scripting have function

$google_ad_handle = @fopen(google_get_ad_url(), 'r');
if ($google_ad_handle) {
while (!feof($google_ad_handle)) {
echo fread($google_ad_handle, 8192);
}
fclose($google_ad_handle);
}


Now most of the hosting provider close(disable) php fopen function. There is a work around to achieve the same thing. Just replace the code with this


function curl_get_contents($url, $timeout=60) {
$timeout = abs((int)$timeout);
$curl = curl_init();
$opts = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => $timeout
);

curl_setopt_array($curl, $opts);
$result = curl_exec($curl);
if($result === false){
user_error(curl_error($curl));
return false;
}
$response = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if($response != 200){
user_error("Received HTTP response of $response.");
}
return $result;
}

$url= google_get_ad_url();
$contents = curl_get_contents($url);
echo $contents;



But My question is Does it break ADSENSE Policy?

I didn't write this code. I found it on a website.

 

leadegroot




msg:4582514
 10:11 am on Jun 9, 2013 (gmt 0)

Does it break Adsense Policy?

No, because Adsense TOS governs _what_ you serve, not _how_ you serve it.

But surely, you would use an include or require rather than an fopen or a curl?

yaashul




msg:4582522
 10:48 am on Jun 9, 2013 (gmt 0)

And how to do that?

leadegroot




msg:4582533
 11:09 am on Jun 9, 2013 (gmt 0)

PHP include function doco [php.net]
?

yaashul




msg:4582534
 11:11 am on Jun 9, 2013 (gmt 0)

I don't know anything about php at all

leadegroot




msg:4582535
 11:27 am on Jun 9, 2013 (gmt 0)

Well, best to get reading then. php.net is definitive and excellent :)

yaashul




msg:4582583
 5:57 pm on Jun 9, 2013 (gmt 0)

But if I use include I wont be able. to set a timeout

leadegroot




msg:4582619
 11:47 pm on Jun 9, 2013 (gmt 0)

fopen and curl are used to include files from other sites/hosts.
It would be inefficient and odd to have your own code on another host. Put it locally.
'include' doesnt need a timeout, it isn't subject to delays.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Google / Google AdSense
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved