You CAN use PHP to generate the AdSense code!

Discussion in 'Guidelines / Compliance' started by mihaidamianov, May 3, 2006.

  1. #1
    To whom it may concern:

    EDIT: This is posted here because some people had doubts about this complying with AdSense TOS. Just to clear things out I wrote AdSense support about this and here's their reply:

    
    Hello Mihai,
    
    As long as the final version of the code, as seen on your website when you
    look at the page source, is identical to code that is provided in your
    accout, you may use PHP to change colors, channels, alternate URLs, etc.
    
    I do recommend being careful, however, since a simple mistake like missing
    quotes could stop your ads from working.
    
    Sincerely, 
    
    David
    The Google AdSense Team
    
    Code (markup):
    Happy coding!
     
    mihaidamianov, May 3, 2006 IP
    LaCabra and Henny like this.
  2. Pammer

    Pammer Notable Member

    Messages:
    3,417
    Likes Received:
    397
    Best Answers:
    0
    Trophy Points:
    260
    #2
    whooaa, i wanna also try that... but i have not find thats like any letter. is this only specials for u.
     
    Pammer, May 3, 2006 IP
  3. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #3
    That's a reply to an enquiry I've sent to AdSense support. Not something special for myself only!
     
    mihaidamianov, May 3, 2006 IP
  4. Fahd

    Fahd Well-Known Member

    Messages:
    2,152
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    100
    #4
    Am I the only one that thinks this is something that is obviously allowed?

    I've been doing this since adsense launched without any problems!
     
    Fahd, May 3, 2006 IP
  5. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #5
    No, I thought that as well, but some thought it's against TOS so I actually wrote AdSense on this. :)
     
    mihaidamianov, May 3, 2006 IP
  6. Cristian Mezei

    Cristian Mezei Notable Member

    Messages:
    3,332
    Likes Received:
    355
    Best Answers:
    0
    Trophy Points:
    213
    #6
    I doubt that a mass message was sent with a mispell, by a Google representative. They are very thourough.

    And i doubt that this message was sent only to one single advertiser.

    Can uou post some headers of the e-mail ?
     
    Cristian Mezei, May 3, 2006 IP
  7. iowadawg

    iowadawg Prominent Member

    Messages:
    10,918
    Likes Received:
    811
    Best Answers:
    0
    Trophy Points:
    380
    #7
    Hate to break it to you, but even google employees can make mistakes!
     
    iowadawg, May 3, 2006 IP
  8. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #8
    PS Grow up! People make mistakes. Doh!..
     
    mihaidamianov, May 3, 2006 IP
  9. Nick_Mayhem

    Nick_Mayhem Notable Member

    Messages:
    3,486
    Likes Received:
    338
    Best Answers:
    0
    Trophy Points:
    290
    #9
    Humm..... I don't know why. But Some of the readymade sites that are available on the internet are also using the same technique.

    That is why PHP is there. :D To format or process the html code before it gets outputted.
     
    Nick_Mayhem, May 3, 2006 IP
  10. Cristian Mezei

    Cristian Mezei Notable Member

    Messages:
    3,332
    Likes Received:
    355
    Best Answers:
    0
    Trophy Points:
    213
    #10
    I am grown up. That's why i ask questions.
     
    Cristian Mezei, May 3, 2006 IP
  11. Mr Crow

    Mr Crow Peon

    Messages:
    1,099
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I think its all a conspiricy ... I dont know the conspiracy is but I just know it must be....

    Now my question

    Is it possible that a programmer can make it look like its my adsense code but actually is his ...

    cause I got tons of traffic going on , but very few page veiws and few few clicks ....
     
    Mr Crow, May 3, 2006 IP
  12. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #12
    If he has access to your server of course he can! You could check from time to time the source of the pages and see what publisher id is in the ads code. If it's not yours, it's someone else's. ;)
     
    mihaidamianov, May 3, 2006 IP
  13. toomuch72

    toomuch72 Peon

    Messages:
    165
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #13
    PHP gives you options that make it quite easy to to print up rotating codes or whatever.

    But you do not have to edit the orginal code to do it. I have shown many times in other posts that you can post using php without ever editing code.
    Why take the chance to edit code?

    Then when you are finished coding are you going to click your own ads to TEST your coding ability? I sure hope not.

    It is so simple to use a php IF statment to print up the code copied and pasted from the google website. You just have to exit out of the php script before pasting using ?>Google code here<? If you attempt to paste the code inside the php script then the actual google code will mess up the php CODE.

    Here it is again

    <?
    $showad="true";
    if ($showad=="true"){?>EXACT GOOGLE CODE COPIED FROM GOOGLES SITE<?}
    ?>
    Code (markup):

    Below is a php script that will show random colored borders(don't forget to srand) You can also do this for different ad sizes.
    <?
    $showad=rand(1,4)
    if ($showad==1){?>Exact copy of google code for ad format with red border<?}
    if ($showad==2){?>Exact copy of google code for ad format with blue border <?}
    if ($showad==3){?>Exact copy of google code for ad format with green border <?}
    if ($showad==4){?>Exact copy of google code for ad format with yellow border<?}
    ?>
    Code (markup):
     
    toomuch72, May 4, 2006 IP
  14. JamesColin

    JamesColin Prominent Member

    Messages:
    7,874
    Likes Received:
    164
    Best Answers:
    1
    Trophy Points:
    395
    Digital Goods:
    1
    #14
    You don't need to click on your ads to test, you just need to review the resulting html code and verify that it's correct.

    "If you attempt to paste the code inside the php script then the actual google code will mess up the php CODE"
    This is incorrect, you just have to escape all quotes or you can use something like :
    $yourvariable = <<<CODE
    Your HTML
    CODE;
    it will not mess up. But you're correct you can have 4 times the same HTML code copied from adsense wizard tool.

    PS: you don't need to srand for rand() to work, it was with old versions of PHP
     
    JamesColin, May 4, 2006 IP
  15. toomuch72

    toomuch72 Peon

    Messages:
    165
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Wow learn something new everyday - I've wasted so many lines of SRAND and I see this change has been around since version 4.2.0.
     
    toomuch72, May 4, 2006 IP
  16. jackburton2006

    jackburton2006 Peon

    Messages:
    5,296
    Likes Received:
    282
    Best Answers:
    0
    Trophy Points:
    0
    #16
    It's the same as what's been discussed before: You can manually change the codes yourself as long as the Adsense CP can duplicate the changes you made. I.e. You can't do anything manually to your code that your CP couldn't do for you. Likewise here.
     
    jackburton2006, May 4, 2006 IP
  17. jumble

    jumble Peon

    Messages:
    142
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #17
    thanks for posting this. it is such a relief that common sense has prevailed!

    hopefully the super paranoid amongst us will read this and finally make the step down to moderately paranoid :)
     
    jumble, May 5, 2006 IP
  18. pwaring

    pwaring Well-Known Member

    Messages:
    846
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    135
    #18
    I don't see what the big deal is - Google can't tell how the Adsense code is generated, only how it appears in the HTML source, so they couldn't possibly ban you for creating it via PHP because how would they know? Also, this site presumably generates the Adsense code by PHP (or at least part of it) to make the revenue sharing feature work.

    I think the lack of common sense is coming from the webmasters, rather than Google.
     
    pwaring, May 5, 2006 IP
  19. kkibak

    kkibak Peon

    Messages:
    1,083
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #19
    this is irrelevant, but theoretically they could tell... if they logged the usage in your account of the generation tool, and you have ads displaying your website in a format that was never generated by them.
     
    kkibak, May 5, 2006 IP
  20. justinwp

    justinwp Peon

    Messages:
    81
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #20
    i've been doing this for awhile now on my blog. readers can change background colors on the entire site including the adsense ads

    justinwp.com
     
    justinwp, May 5, 2006 IP