dan@viewex.co.uk: Feb 10 04:01AM -0800 Hi, Can I use AdUnit.getAdCode() in PHP? I can't find it in get_class-methods() of my ad unit. How do I generate the actual HTML ad code (async + sync) rather than returning the plain number? Cheers |
"Dean Lukies (Adsense API Team)" <adsenseapiadvisor+lukiesd@google.com>: Feb 10 11:43AM -0800 Hi, Is this what you are looking for? $result = $service->accounts_adunits->getAdCode($accountId, $adClientId, $adUnitId); print $result['adCode']; thanks, Dean PS: I wanted to remind people about stackoverflow.com and the adsense-api tag <http://www.google.com/url?q=http%3A%2F%2Fstackoverflow.com%2Fquestions%2Ftagged%2Fadsense-api&sa=D&sntz=1&usg=AFQjCNGn9LRNfIvWoBht56pFQFltGGPxwg> ! |
galeksic <agencijaspecihost@gmail.com>: Feb 10 11:51AM -0800 (Sorry, Dean. I was almost at the end of my message when I saw yours, so I'll post it anyway :) I think you can, but of course - just to get and store the code in your database. (You don't want to call API for every ad request.) https://developers.google.com/adsense/management/v1.4/reference/accounts/adunits/getAdCode https://github.com/google/google-api-php-client/blob/master/src/Google/Service/AdSense.php#L1653 /** * Get ad code for the specified ad unit. (adunits.getAdCode) * * @param string $adClientId * Ad client with contains the ad unit. * @param string $adUnitId * Ad unit to get the code for. * @param array $optParams Optional parameters. * @return Google_Service_AdSense_AdCode */ public function getAdCode($adClientId, $adUnitId, $optParams = array()) { $params = array('adClientId' => $adClientId, 'adUnitId' => $adUnitId); $params = array_merge($params, $optParams); return $this->call('getAdCode', array($params), "Google_Service_AdSense_AdCode"); } $result = $service->accounts_adunits->getAdCode($adClientId, $adUnitId, $optParams); { "kind": "adsense#adCode", "adCode": "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>\n<!-- * * * -->\n<ins class=\"adsbygoogle\"\n style=\"display:block\"\n data-ad-client=\"ca-pub-123\"\n data-ad-slot=\"456\"\n data-ad-format=\"auto\"></ins>\n<script>\n(adsbygoogle = window.adsbygoogle || []).push({});\n</script>" } As far I'm aware with getAdCode() you can get only one version - for responsive asynchronous, and for fixed sized synchronous. (Not 100% sure about other ad sizes - custom sized, link units.) |
dan@viewex.co.uk: Feb 10 03:56AM -0800 Hi, The endpoint hitting page returns the same error. Just the same 403 User does not have an AdSense account. I've invited the new user and accepted the invite and can access the normal UI from the new user, I just can't do any API calls. Confused, Dan |
"Dean Lukies (Adsense API Team)" <adsenseapiadvisor+lukiesd@google.com>: Feb 10 07:31AM -0800 Resolved this offline with Dan but wanted to post so folks know what happened; it can take up to 24 hours for a new account to get API access. thanks, Dean |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to adsense-api+unsubscribe@googlegroups.com. |
No comments:
Post a Comment