Showing posts with label Pinterest. Show all posts
Showing posts with label Pinterest. Show all posts

Wednesday, April 30, 2014

Pinterest Javascript and PHP Integration

Pinterest Sample Code Javascript and PHP Integration , Invite people to pin things from your website using Pin It button , Invite people to follow you on Pinterest from your site using Follow button.

  Source Code
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript">
                (function (d, buildThese) {
                    var homeScript, newScript, n = buildThese.length, i;
                    for (i = 0; i < n; i = i + 1) {
                        newScript = d.createElement('SCRIPT');
                        newScript.type = 'text/javascript';
                        newScript.async = true;
                        newScript.src = buildThese[i];
                        homeScript = d.getElementsByTagName('SCRIPT')[0];
                        homeScript.parentNode.insertBefore(newScript, homeScript);
                    }
                }(document, [
                    '//assets.pinterest.com/js/pinit.js'
                    /* load more third-party JavaScript here */
                ])
            );
        </script>
    </head>
    <body>
        <!-- Pin It button: Invite people to pin things from your website.-->
        
        <?php
            $url            = urlencode("<YOUR-URL>");
            $media          = urlencode("<YOUR-IMAGE-URL>");
            $description    = "<YOUR-DESCRIPTION>";
            $dataPinConfig  = "above"; /* above, beside, none */
            $buttonPin      = "buttonPin"; /* buttonPin, buttonFollow*/
        ?>
        
        <a 
           data-pin-config  ="<?=$dataPinConfig;?>" 
           href             ="//pinterest.com/pin/create/button/?url=<?=$url;?>&media=<?=$media;?>&description=<?=$description;?>" 
           data-pin-do      ="<?=$buttonPin;?>" >
            <img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" />
        </a>
        
        <!-- Follow button: Invite people to follow you on Pinterest from your site.-->
        
        <?php
            $fullName       = "<YOUR-FULL-NAME>";
            $buttonPin      = "buttonFollow";
        ?>
        
        <a 
            data-pin-do="<?=$buttonPin;?>" 
            href="//pinterest.com/pinterest/"><?=$fullName;?>
        </a>
        
    </body>
</html>



Genesis Framework for WordPress