BUG: code snippet returned is not valid

3 views
Skip to first unread message

flixya

unread,
Aug 27, 2009, 9:35:42 AM8/27/09
to AdSense API Forum
I haven't checked how long this has been the case, but the code-
snippets returned are not valid. It seems that the less-than
characters (<) are missing.

See returned snippet:

<h2>Method Called</h2><b>method:</b>
getSyndicationService<br><b>param:</b>
<br>&lt;ns1:getSyndicationService<br> xmlns:ns1=&quot;http://
www.google.com/api/adsense/v3&quot;&gt;<br>&lt;synServiceType&gt;<br>&lt;value&gt;ContentAds<br>&lt;/value&gt;<br>&lt;/synServiceType&gt;<br>&lt;/ns1:getSyndicationService&gt;<br>

<h2>Service Id</h2>
<b>synServiceId:</b> ca-pub-0503594684327159<br>
<h2>Request</h2>
<pre>POST /api/adsense/v3/AccountService HTTP/1.0
Host: www.google.com
User-Agent: NuSOAP/0.7.2 (1.94)
Content-Type: text/xml; charset=UTF-8
SOAPAction: &quot;urn:getSyndicationService&quot;
Content-Length: 726

<br>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?
&gt;<br>&lt;SOAP-ENV:Envelope<br> xmlns:SOAP-ENV=&quot;http://
schemas.xmlsoap.org/soap/envelope/&quot;<br> xmlns:xsd=&quot;http://
www.w3.org/2001/XMLSchema&quot;<br> xmlns:xsi=&quot;http://
www.w3.org/2001/XMLSchema-instance&quot;<br> xmlns:SOAP-
ENC=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;<br>
xmlns:ns0=&quot;http://www.google.com/api/adsense/
v3&quot;&gt;<br>&lt;SOAP-
ENV:Header&gt;<br>&lt;developer_email&gt;XXXXXX<br>&lt;/
developer_email&gt;<br>&lt;developer_password&gt;XXXXX<br>&lt;/
developer_password&gt;<br>&lt;client_id&gt;ca-
pub-0503594684327159<br>&lt;/client_id&gt;<br>&lt;/SOAP-
ENV:Header&gt;<br>&lt;SOAP-
ENV:Body&gt;<br>&lt;ns1:getSyndicationService<br>
xmlns:ns1=&quot;http://www.google.com/api/adsense/
v3&quot;&gt;<br>&lt;synServiceType&gt;<br>&lt;value&gt;ContentAds<br>&lt;/
value&gt;<br>&lt;/synServiceType&gt;<br>&lt;/
ns1:getSyndicationService&gt;<br>&lt;/SOAP-ENV:Body&gt;<br>&lt;/SOAP-
ENV:Envelope&gt;</pre>

<h2>Response</h2>
<pre>HTTP/1.1 200 OK
Content-Type: text/xml; charset=UTF-8
Transfer-Encoding: chunked
Date: Thu, 27 Aug 2009 13:31:40 GMT
Expires: Thu, 27 Aug 2009 13:31:40 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
Server: GFE/2.0

<br>&lt;?xml version=&#039;1.0&#039; encoding=&#039;UTF-8&#039;?
&gt;<br>&lt;soapenv:Envelope<br> xmlns:soapenv=&quot;http://
schemas.xmlsoap.org/soap/envelope/
&quot;&gt;<br>&lt;soapenv:Body&gt;<br>&lt;ns:getSyndicationServiceResponse<br>
xmlns:ns=&quot;http://www.google.com/api/adsense/
v3&quot;&gt;<br>&lt;return&gt;<br>&lt;type&gt;<br>&lt;value&gt;ContentAds<br>&lt;/
value&gt;<br>&lt;/type&gt;<br>&lt;id&gt;ca-
pub-0503594684327159<br>&lt;/id&gt;<br>&lt;/return&gt;<br>&lt;/
ns:getSyndicationServiceResponse&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/
soapenv:Envelope&gt;</pre>

<h2>Method Called</h2><b>method:</b> generateAdCode<br><b>param:</b>
<br>&lt;ns1:generateAdCode<br> xmlns:ns1=&quot;http://
www.google.com/api/adsense/v3&quot;&gt;<br>&lt;synServiceId&gt;ca-pub-0503594684327159<br>&lt;/synServiceId&gt;<br>&lt;adStyle&gt;<br>&lt;name&gt;demoStyle<br>&lt;/name&gt;<br>&lt;borderColor&gt;#0000FF<br>&lt;/borderColor&gt;<br>&lt;backgroundColor&gt;#FFFFFF<br>&lt;/backgroundColor&gt;<br>&lt;titleColor&gt;#FF0000<br>&lt;/titleColor&gt;<br>&lt;textColor&gt;#00FF00<br>&lt;/textColor&gt;<br>&lt;urlColor&gt;#FFFF00<br>&lt;/urlColor&gt;<br>&lt;/adStyle&gt;<br>&lt;adUnitType&gt;<br>&lt;value&gt;TextOnly<br>&lt;/value&gt;<br>&lt;/adUnitType&gt;<br>&lt;layout&gt;<br>&lt;value&gt;728x90<br>&lt;/value&gt;<br>&lt;/layout&gt;<br>&lt;alternate&gt;#FFFFFF<br>&lt;/alternate&gt;<br>&lt;isFramedPage
type=&quot;xsd:boolean&quot;&gt;false<br>&lt;/
isFramedPage&gt;<br>&lt;channelName xsi:nil=&quot;true&quot;/
&gt;<br>&lt;cornerStyles&gt;<br>&lt;value&gt;DEFAULT<br>&lt;/
value&gt;<br>&lt;/cornerStyles&gt;<br>&lt;/ns1:generateAdCode&gt;<br>

<h2>Snippet</h2>
<pre>script type=&quot;text/javascript&quot;&gt;!--
google_ad_client=&quot;pub-0503594684327159&quot;;
google_ad_host=&quot;pub-3154006528813426&quot;;
google_alternate_color=&quot;FFFFFF&quot;;
google_ad_width=728;
google_ad_height=90;
google_ad_format=&quot;728x90_as&quot;;
google_ad_type=&quot;text&quot;;
google_color_border=&quot;0000FF&quot;;
google_color_bg=&quot;FFFFFF&quot;;
google_color_link=&quot;FF0000&quot;;
google_color_url=&quot;FFFF00&quot;;
google_color_text=&quot;00FF00&quot;;
//--&gt;/script&gt;

script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/
show_ads.js&quot;&gt;
/script&gt;
</pre>



Regards,
Florian

flixya

unread,
Aug 27, 2009, 9:52:40 AM8/27/09
to AdSense API Forum
The issue seems to be that the return value is following:

&lt;script type="text/javascript">&lt;!--
google_ad_client="pub-0503594684327159";
google_ad_host="pub-3154006528813426";
google_alternate_color="FFFFFF";
google_ad_width=728;
google_ad_height=90;
google_ad_format="728x90_as";
google_ad_type="text";
google_color_border="0000FF";
google_color_bg="FFFFFF";
google_color_link="FF0000";
google_color_url="FFFF00";
google_color_text="00FF00";
//-->&lt;/script>
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
&lt;/script>

The less-than characters already are html-encoded.
We are using nusoap.php,v 1.94 2005/08/04.

Regards,
Florian

On 27 Aug., 15:35, flixya <fli...@gmail.com> wrote:
> I haven't checked how long this has been the case, but the code-
> snippets returned are not valid. It seems that the less-than
> characters (<) are missing.
>
> See returned snippet:
>
> <h2>Method Called</h2><b>method:</b>
> getSyndicationService<br><b>param:</b>
> <br>&lt;ns1:getSyndicationService<br>    xmlns:ns1=&quot;http://www.google.com/api/adsense/v3"><br>&lt;synServiceType&gt;<br>&lt;value&gt;ContentAds<br>&lt;/value&gt;<br>&lt;/synServiceType&gt;<br>&lt;/ns1:getSyndicationService&gt;<br>
>
> <h2>Service Id</h2>
> <b>synServiceId:</b> ca-pub-0503594684327159<br>
> <h2>Request</h2>
> <pre>POST /api/adsense/v3/AccountService HTTP/1.0
> Host:www.google.com
> User-Agent: NuSOAP/0.7.2 (1.94)
> Content-Type: text/xml; charset=UTF-8
> SOAPAction: &quot;urn:getSyndicationService&quot;
> Content-Length: 726
>
> <br>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?
> &gt;<br>&lt;SOAP-ENV:Envelope<br>    xmlns:SOAP-ENV=&quot;http://
> schemas.xmlsoap.org/soap/envelope/&quot;<br>    xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema"<br>    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance"<br>    xmlns:SOAP-
> ENC=&quot;http://schemas.xmlsoap.org/soap/encoding/"<br>
> <br>&lt;ns1:generateAdCode<br>    xmlns:ns1=&quot;http://www.google.com/api/adsense/v3"><br>&lt;synServiceId&gt;ca-pub-0503594684327159<br>&lt;/synServiceId&gt;<br>&lt;adStyle&gt;<br>&lt;name&gt;demoStyle<br>&lt;/name&gt;<br>&lt;borderColor&gt;#0000FF<br>&lt;/borderColor&gt;<br>&lt;backgroundColor&gt;#FFFFFF<br>&lt;/backgroundColor&gt;<br>&lt;titleColor&gt;#FF0000<br>&lt;/titleColor&gt;<br>&lt;textColor&gt;#00FF00<br>&lt;/textColor&gt;<br>&lt;urlColor&gt;#FFFF00<br>&lt;/urlColor&gt;<br>&lt;/adStyle&gt;<br>&lt;adUnitType&gt;<br>&lt;value&gt;TextOnly<br>&lt;/value&gt;<br>&lt;/adUnitType&gt;<br>&lt;layout&gt;<br>&lt;value&gt;728x90<br>&lt;/value&gt;<br>&lt;/layout&gt;<br>&lt;alternate&gt;#FFFFFF<br>&lt;/alternate&gt;<br>&lt;isFramedPage

Google AdSense API Support Team

unread,
Aug 27, 2009, 1:57:27 PM8/27/09
to AdSense API Forum
Florian,

I know we already handled this over email, but just for the sake of
anyone else reading: ad code responses have always been like this.
Since we're returning an XML document, we need to ensure that our ad
code response is parsed as a complete string, instead of a few invalid
XML elements, which is how it would be perceived if we had retained
the < > groupings. We accomplish this by using &lt; instead of '<'
and expect the developer to reverse the conversion before injecting
the code into the publisher's page.

Cheers,
Wes
AdSense API
> > <br>&lt;ns1:getSyndicationService<br>    xmlns:ns1=&quot;http://www.google.com/api/adsense/v3"><br>&lt;synServiceType&gt;<br>&lt;value&gt;ContentAds<br>&lt;/value&gt;<b r>&lt;/synServiceType&gt;<br>&lt;/ns1:getSyndicationService&gt;<br>
> > v3&quot;&gt;<br>&lt;return&gt;<br>&lt;type&gt;<br>&lt;value&gt;ContentAds<b r>&lt;/
> > value&gt;<br>&lt;/type&gt;<br>&lt;id&gt;ca-
> > pub-0503594684327159<br>&lt;/id&gt;<br>&lt;/return&gt;<br>&lt;/
> > ns:getSyndicationServiceResponse&gt;<br>&lt;/soapenv:Body&gt;<br>&lt;/
> > soapenv:Envelope&gt;</pre>
>
> > <h2>Method Called</h2><b>method:</b> generateAdCode<br><b>param:</b>
> > <br>&lt;ns1:generateAdCode<br>    xmlns:ns1=&quot;http://www.google.com/api/adsense/v3"><br>&lt;synServiceId&gt;ca-pub-0503594684327159<br>&lt;/synServiceId&gt;< br>&lt;adStyle&gt;<br>&lt;name&gt;demoStyle<br>&lt;/name&gt;<br>&lt;borderC olor&gt;#0000FF<br>&lt;/borderColor&gt;<br>&lt;backgroundColor&gt;#FFFFFF<b r>&lt;/backgroundColor&gt;<br>&lt;titleColor&gt;#FF0000<br>&lt;/titleColor& gt;<br>&lt;textColor&gt;#00FF00<br>&lt;/textColor&gt;<br>&lt;urlColor&gt;#F FFF00<br>&lt;/urlColor&gt;<br>&lt;/adStyle&gt;<br>&lt;adUnitType&gt;<br>&lt ;value&gt;TextOnly<br>&lt;/value&gt;<br>&lt;/adUnitType&gt;<br>&lt;layout&g t;<br>&lt;value&gt;728x90<br>&lt;/value&gt;<br>&lt;/layout&gt;<br>&lt;alter nate&gt;#FFFFFF<br>&lt;/alternate&gt;<br>&lt;isFramedPage

Florian

unread,
Aug 27, 2009, 2:26:55 PM8/27/09
to AdSense API Forum
Thanks.

I updated the server the other day. Perhaps a new version of some
library is causing this issue.

What happens is that the html-encoded less-than is removed by soap for
some reason.

This is the original code:
$response = $client->call('generateAdCode', $parameters, $namespace);
$snippet = htmlentities($response['return'],ENT_QUOTES); // html-
encode the whole thing

Now I'm just using a workaround that parses the snippet out of the
$client->responseData.

Regards,
Florian

On 27 Aug., 19:57, Google AdSense API Support Team <adsenseapi-
Reply all
Reply to author
Forward
0 new messages