Skip to main content

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...

LogIn With Facebook and Import Data

<!DOCTYPE html >

<html>
<head>
    <script src="js/jquery.js"></script>
  
</head>
<body>
<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '464794743666929', // Set YOUR APP ID
      channelUrl : 'http://localhost:8000/facebook/', // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });

    FB.Event.subscribe('auth.authResponseChange', function(response)
    {
     if (response.status === 'connected')
    {
        document.getElementById("message").innerHTML +=  "<br>Connected to Facebook";
        //SUCCESS

    } 
    else if (response.status === 'not_authorized')
    {
        document.getElementById("message").innerHTML +=  "<br>Failed to Connect";

        //FAILED
    } else
    {
        document.getElementById("message").innerHTML +=  "<br>Logged Out";

        //UNKNOWN ERROR
    }
    });

    };

    function Login()
    {

        FB.login(function(response) {
           if (response.authResponse)
           {
                getUserInfo();
            } else
            {
             console.log('User cancelled login or did not fully authorize.');
            }
         },{scope: 'email,user_photos,user_videos,user_birthday'});

    }
  
    //https://developers.facebook.com/docs/graph-api/reference/user/
  function getUserInfo() {
        FB.api('/me', function(response) {
        alert("myObject is " + response.hometown.toSource());
          var str='<center><img src="https://graph.facebook.com/'+response.id+'/picture?type=large"/></center>'
          str+="<b>Name</b> : "+response.name+"<br>";
          str +="<b>Link: </b>"+response.link+"<br>";
          str +="<b>Username:</b> "+response.username+"<br>";
          str +="<b>first_name:</b> "+response.first_name+"<br>";
          str +="<b>last_name:</b> "+response.last_name+"<br>";
          str +="<b>id: </b>"+response.id+"<br>";
          str +="<b>Email:</b> "+response.email+"<br>";
          str +="<b>bio:</b> "+response.bio+"<br>";
          str +="<b>education:</b> "+response.education+"<br>";
          str +="<b>favorite_athletes:</b> "+response.favorite_athletes+"<br>";
          str +="<b>location:</b> "+response.location+"<br>";
          str +="<b>Birthday:</b> "+response.birthday+"<br>";
          str +="<b>Hometown:</b> "+response.hometown['name']+"<br>";
          str +="<b>Gender:</b> "+response.gender+"<br>";
          str +="<b>Location:</b> "+response.location['name']+"<br>";
          str +="<input type='button' value='Get Photo' onclick='getPhoto();'/>";
          str +="<input type='button' value='Logout' onclick='Logout();'/>";
           str +="<input type='button' value='Friends Data' onclick='friends();'/>";
          document.getElementById("status").innerHTML=str;

    });
    }
  
    function getPhoto()
    {
      FB.api('/me/picture?type=large', function(response) {

          var str="<br/><b>Pic</b> : <img src='"+response.data.url+"'/>";
          document.getElementById("status").innerHTML+=str;

    });

    }
    function Logout()
    {
        FB.logout(function(){document.location.reload();});
    }

  // 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 friends() {
            FB.api('/me/friends', {
                fields : 'id, name, picture'
            }, function(response) {
                if (response.error) {
                    //alert(JSON.stringify(response.error));
                } else {
              
                  
                                var datadiv = document.getElementById('status');
                                var result=response.data;
                                var html='<br/><br/><input type="text" class="friendsearch" onkeyup="searchFriends(this)" placeholder="Search" style="border-radius:4px;width:300px;height:30px;"/><br/><br/>';
                              
                                 html+='<ul data-role="listview" data-split-icon="gear" data-filter="true" data-theme="c">';
                                response.data.forEach(function(item) {
                                    //alert(result[i].name);
                                    //alert(result[i].id);
                                    var keyword=item.name;
                                    keyword = keyword.replace(/\s/g, '');
                                        html+='<div class="allfriends" fname='+keyword+'>';
                                                                html+='<a href="#" style="padding-top: 0px;padding-bottom: 0px;padding-right: 0px;padding-left: 0px;">';
                                                                html+='<label style="border-top-width: 0px;margin-top: 0px;border-bottom-width: 0px;margin-bottom: 0px;border-left-width: 0px;border-right-width: 0px;" data-corners="false">';
                                                                html+='<fieldset data-role="controlgroup" >';                                                     
                                                               // html+='<input type="checkbox" name="checkbox-2b" id="checkbox-2b" class="fb_users" fid="'+item.id+'" onclick="facebookusersToInviteEvent(this,'+item.id+')"data-theme="c"/>';
                                                                html+=' <img   class="imege_list"  src="'+item.picture.data.url+'"  style="border-radius: 4px !important;float:right;" width="100" height="130" />';
                                                                html+='<label for="checkbox-2b" style="border-top-width: 0px;margin-top: 0px;border-bottom-width: 0px;margin-bottom: 0px;border-left-width: 0px;border-right-width: 0px;">';
                                                                html+='<label  style="padding:10px 0px 0px 0px;">';
                                                                html+='<h3 style="padding-top:13px;">'+item.name+'</h3>';
                                                                html+='</label>';
                                                                html+='</label>';
                                                                html+=' </fieldset>'  
                                                                html+='</label>';
                                                                html+=' </a></div>';
                                                               // html+='</li>';
                                });
                                html+="</ul>";
                                                              console.log(html)
                            document.getElementById("status").innerHTML+=html;
                }
              
            });
            }
          
    function searchFriends(){
   var keyword=$(".friendsearch").val();
   keyword = keyword.replace(/\s/g, '');
   console.log(keyword);
    if(keyword == ''){
        $('.allfriends').show();
    }else{
        $('.allfriends').each(function(){
                         var fname = $(this).attr('fname');
                         var nfname=fname.toLowerCase();
                         var n=nfname.indexOf(""+keyword+"");
                         if(n >=0){          
                         $(this).show();                                                                                          
                            }else{                                                                                      
                         $(this).hide();                                                                                              
                         }
                         });                                                                     
    }
}  
        </script>
<div align="center">
<h2>Facebook OAuth Javascript Demo</h2>

<div id="status">
 Click on Below Image to start the demo: <br/>
<img src="http://hayageek.com/examples/oauth/facebook/oauth-javascript/LoginWithFacebook.png" style="cursor:pointer;" onclick="Login()"/>
</div>

<br/><br/><br/><br/><br/>

<div id="message">
Logs:<br/>
</div>

</div>
</body>
</html>

Comments

Popular posts from this blog

Create Signature pad with save on database in php

Create Signature pad with save on database in php 1.create a folder images index.php ============   <!DOCTYPE >     <head>     <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />     <title>Signature Pad</title>     <script type="text/javascript" src="jquery-1.8.0.min.js"></script>     <script type="text/javascript"> $(document).ready(function () {     /** Set Canvas Size **/     var canvasWidth = 400;     var canvasHeight = 100;     /** IE SUPPORT **/     var canvasDiv = document.getElementById('signaturePad');     canvas = document.createElement('canvas');     canvas.setAttribute('width', canvasWidth);     canvas.setAttribute('height', canvasHeight);     canvas.setAttribute('id', 'canvas');     canvasDiv.appendChild(canvas);    ...

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...

Smarty Pagination with php mysql

Smarty Pagination with php mysql ------------------------------------------------------------- --------------------------------------------------------------  <?php  Pagination using PHP,Smarty And MySql $sql="SELECT * FROM `fieldname1` WHERE is_active='Y' ORDER BY fieldmame2"; $rs=mysql_query($sql); $num=mysql_num_rows($rs); $i=0; /*while ($row = mysql_fetch_array($rs)) { $arr1[$j] = $row; $j++; }*/ //////////////////////////////////////////// if (!(isset($pagenum))) { $pagenum = 1; } //Here we count the number of results //Edit $data to be your query $rows = $num; //This is the number of results displayed per page $page_rows = 2; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'LIMIT ' .($pagen...