Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. 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>



Invite Friends In FACEBOOK with API Apprequest Method Implementation

This sample Code is a Facebook API method implementation which uses Javascript SDK. A simple source code that can invite your friends to use your Facebook Application.

Source Code


 <!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <script type="text/javascript">
            window.fbAsyncInit = function() {
                FB.init({
                    appId: "<YOUR-APP-ID>",
                    status: true,
                    cookie: true
                });
            };
            
            // Load the SDK Asynchronously
            (function(d){
                var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
                if (d.getElementById(id)) {return;}
                js = d.createElement('script'); js.id = id; js.async = true;
                js.src = "//connect.facebook.net/en_US/all.js";
                ref.parentNode.insertBefore(js, ref);
            }(document));
            
            function invite_your_friends() {
                FB.ui({
                    method: "apprequests",
                    message: "Check out this Fantastic App!"
                }, invite_your_friends_callback);
            }
            
            function invite_your_friends_callback(response) {
                console.log(response);
            }

  </script>
  <center>
      <a href="javascript:;" onclick="invite_your_friends();">
          <h3>Invite Your Friends and Share this Fantastic App!</h3>
      </a>
  </center>
    </body>
</html>



Genesis Framework for WordPress