Wednesday, 9 April 2014

how does facebook check-in works with Bing maps API with facebook pages (PART 1/3)

This is another post after Facebook custom stories for facebook application which made me more crazy to learn about the Bing Maps API to retrieve maps using AJAX 7 technique or REST API service provided by MICROSOFT.

you guys would be fascinated in updating status and photos ,events and others with check-in places and tag with your friends.Generally facebook always displays the Bing Maps for those check-in.These check-ins are actually born at Pages/place you create and give access via GPS to locate your device and get Latitude and longitude details to query Bing maps API and obtain maps to display to users and friends.



There are lot of parameters in getting map for exact location and corresponding maps for various platforms with various methods.i am here discussing about web(desktop) Rest API request and AJAX 7.

first of all let us see how to make location based request with BING API in this post:

1)
Go to Bing Maps API and register a new Application with Microsoft Live Account.


2) Create a Bing Map KEY for retrieval and authentication purpose(generally making API calls secure from anonymous calls)

3) Create with BASIC keys and provide as NON PROFIT as category for safer side usage.

4) Copy your KEY which is registered with correct Domain name URL.

Lets have a look at the simplest BING MAPS API CODE to retrieve location based on QUERY.
     <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

<script type="text/javascript">

var map = null;

function GetMap()
{
// Initialize the map
map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:"Aoyuj93YnzHbS8ZBLA6sdcvsdvzcxvcsyv2ASBjCJlICSIVobIZt3bZhwTzr-egVhMmlf-f8IKpM", mapTypeId:Microsoft.Maps.MapTypeId.road});

}

function ClickGeocode(credentials)
{
map.getCredentials(MakeGeocodeRequest);
}

function MakeGeocodeRequest(credentials)
{

var geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations?query=" + encodeURI(document.getElementById('txtQuery').value) + "&output=json&jsonp=GeocodeCallback&key=" + credentials;

CallRestService(geocodeRequest);
}

function GeocodeCallback(result)
{
alert("Found location: " + result.resourceSets[0].resources[0].name);

if (result &&
result.resourceSets &&
result.resourceSets.length > 0 &&
result.resourceSets[0].resources &&
result.resourceSets[0].resources.length > 0)
{
// Set the map view using the returned bounding box
var bbox = result.resourceSets[0].resources[0].bbox;
var viewBoundaries = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(bbox[0], bbox[1]), new Microsoft.Maps.Location(bbox[2], bbox[3]));
map.setView({ bounds: viewBoundaries});

// Add a pushpin at the found location
var location = new Microsoft.Maps.Location(result.resourceSets[0].resources[0].point.coordinates[0], result.resourceSets[0].resources[0].point.coordinates[1]);
var pushpin = new Microsoft.Maps.Pushpin(location);
map.entities.push(pushpin);
}
}

function CallRestService(request)
{
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", request);
document.body.appendChild(script);
}

</script>
See the Pen facebook like check-in [part 1/2] basic usage of bing API by s.shivasurya (@shivasurya) on CodePen.


Demo here - LINK 

so what happens in above code as simple and short and sweet:

1) we got the key from Bing API official used them rite at the place (credential mentioned in code)

2) using the key we made a user query place(eg:coimbatore) and which is sent via URL as REST API CALL with javascript help.

3) after STATUS 200 we get the result in JSON/XML (as we mention in URL PART)

4) by appending the result in browser we could get the place with Pushpin and we could get LATITUDE/LONGITUDE info also here which can be stored in database.

5) note that the resultant map is in form of Image as tiles (parts) can be saved and used personally.and the link can be useful later part.

thus we have successfully queried a place with longitud/latitude and an image.with this in next tutorial i would explain how pages/events/status check-in's works and btw we could create simple Check-in applications also.

i have tested this above code worled well and came across many errors! you can discuss errors with me hope i can provide solutions as comments/Email,Share is Care.

Saturday, 5 April 2014

working with chart.js to create graphs,charts using javascript

I was monitoring my traffic last few days and was viewing graph of visitors for my site and was curious to know the way of generation of chart in Blogger to display the traffic.& finally found an excellent solution for my own Admin site also.solution was - Chart.js. Humans are always attracted to the visually drawn graphs and charts rather than raw data in plain sheets.Thus,Chart.js enhances to create charts and load the graph easily in to web pages since it is javascript plugin.as we come across the comparison of data charts could make easy to differ one from the other and makes user to understand soon about it,Any way those carts will be very useful for the ADMIN panel for many back end website to analyse data and compare them.There are lot of Bootstrap themes to create admin with charts but this tutorial may enhance you to create your own charts for your website with data given.


Installation of Chart.js : Download

Just like how we use javascript in our sites,attach them as in <head></head> tags using script src.

<script src="chart.js"></script>

Generating chart :

since this chart.js uses HTML5 we use <canvas> tag to load our charts in web pages with referencing respecttive id's

<canvas id="preferred_name" height="preferred height" 
width="preferred width"></canvas>

Javascript to create a chart :

generally Chart.js gives many flavours such as LINE,BAR,RADAR,POLAR,PIE,DOUGH NUT chart types.
Essential part of the chart is Data that to in number formats and Labels and Data Range to prepare a chart.By using the below statement we could call the function with possible arguments through them.generally we pass DATA and OPTIONS as arguments to generate a graph in canvas area.

var ctx = document.getElementById("canvas_id_here").getContext("2d");
new Chart(ctx).Line(data,options);

the above code calls the function with specific arguments i.e DATA and OPTIONS.

data (argument of above function) :

data is generally declared as VAR in javascript and by further we could break it up with three different options such as LABELS as array ,DATASETS that contains some CSS property and RAW-DATA.
lets have a look at the LABEL which is declared as array i.e

label:['India','south africa','Australia','USA']

now about some CSS property for our graph look i.e they have been determined by DATASETS with that RAW-DATA is combined as array which is essentials to generate graph, i.e

datasets:
[{
fillColor:"rgba(your specified value for fill color in r,g,b,a format)",
strokeColor:"rgba(your specified value for strokes colour in r,g,b,a format)",
pointColor:"rgba(your specified color option in rgba format)",
pointStrokeColor:"hexa decimal value for colour",
data:[45,42,15,14,17,62,14]
}
]

Options(argument to function mentioned above):

there are so many options which defines our graph look add some css,Those Options are simple for readers to interpret so i don't want to explain those,just go through the options code.

Line.defaults = {
scaleOverlay : false,
scaleOverride : false,
scaleSteps : null,
scaleStepWidth : null,
scaleStartValue : null,
scaleLineColor : "rgba(0,0,0,.1)",
scaleLineWidth : 1,
scaleShowLabels : true,
scaleLabel : "<%=value%>",
scaleFontFamily : "'Arial'",
scaleFontSize : 12,
scaleFontStyle : "normal",
scaleFontColor : "#666",
scaleShowGridLines : true,
scaleGridLineColor : "rgba(0,0,0,.05)",
scaleGridLineWidth : 1,
bezierCurve : true,
pointDot : true,
pointDotRadius : 3,
pointDotStrokeWidth : 1,
datasetStroke : true,
datasetStrokeWidth : 2,
datasetFill : true,
animation : true,
animationSteps : 60,
animationEasing : "easeOutQuart",
onAnimationComplete : null

}

Final word:

Thus combining the above resource we could generate charts graphs in efficient manner.I have given only a start up use the resource from Chart.js official website for download and verfication & documentations to get more stuffs loaded.share is care.I will provide the demo soon as possible.

Friday, 21 March 2014

Load image url and choose like Google photos using php & jquery

we would be fascinated by using Google to upload photos while mean time we could grab the image by using JQuery and with some inbuilt functions in PHP.I have given a simple script to load the image from the given url and handled some Error occurings with the help of inbuilt functions.Any way You must need minimum PHP version to test this sample because the built in function i have used must have 5.3.2 version minimum as per Docs of PHP.

A final capture from my localhost to grab image from url!
have a look at my code at codepen widget!
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#contentbox").keyup(function()
{
var content=$(this).val();
var urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;

var url= content.match(urlRegex);

if(url.length>0)
{
$("#flash").html('<img src="http://www.llandudnohostel.co.uk/assets/images/ajax-loader.gif">');
$("#linkbox").slideDown('show');
$.get("i.php?url="+url,function(data)
{
var expression=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/gi;
var regex = new RegExp(expression);
var t = data;
if (t.match(regex) )
{
document.getElementById("linkbox").innerHTML = '';
$("#linkbox").html("<img src='"+data+"' class='img'/>");
}
else
{
$("#linkbox").html("<h3><span class=\"error\">"+data+"</span></h3>");
}
});
}
else
{ $("#flash").html('<span>Enter valid url !okay?! </span>');
}
return false;
});
});
</script>
See the Pen grab image using url by s.shivasurya (@shivasurya) on CodePen.


php code:

This php code uses get parameter url and undergoes many test to check errors and atlast prints the url which is parsed with JQuery and displayed on clients page.

<?php
if($_GET['url']) {
$shiva=$_GET['url'];
  if($info = new SplFileInfo($shiva)) {
     if($s=$info->getExtension()) {
        $allowedExts = array("gif", "jpeg", "jpg", "png");
          if(in_array($s, $allowedExts)) {
             $size=getimagesize($shiva);
               if($size && $size!=0 ) {
                  $img = $_GET['url'];
                    echo $img;
                } else{echo "size error";}
            } else{echo "existence array error";}
      }else{echo "extension error";}
   }else{echo "file error";}
}
else{echo "error";}
?>

Since i'm currently using free hosting and it is not above 5.3.2 version  :D sorry i couldn't provide however i tried in my Localhost !if u get any error just mail me or comment below.share is care. 

Saturday, 15 March 2014

creating facebook custom stories for facebook application - learn more @i-visionblog.com

we would be fascinated in viewing the status updates,photo updates and as well as many actions that are taking place inside the Facebook.using facebook application we could create custom stories and could be posted inside facebook using such custom stories.Recently i was amazed while using Pintrest and their posts on facebook activity named as pinning action on their wall.This lead me to learn more about Graph API. and posting custom story creation.I was wandering around google for tutorials but facebook developers & stackoverflow gave me brilliant docs to follow and build the custom-stories for facebook application.


creating facebook custom stories for facebook application - learn more @i-visionblog.com

procedure:
first of all for all developers must register in the developer about their new app for any platform provided facebook.it may either windows,android,facebook app,website application,i-os application or it may be a game running on facebook canvas.register with correct URL, domain name, and provide with Developer e-mail.

1)Now go to Graph API side tab listed in left column and click that link.
2)You will be showing with Create new stories (custom).



3)Define new story with action and object.
let us see some terms about action and object below.

action: 

action is something you do on facebook and represent the post and provide a view to the friends and you as post in timeline as well as news-feed. For example SHARE is action made by the user and they are represented as post in timeline and we could post in friends timeline.

object:

object is something which is shared,added or done something on facebook.They are things and important part of the post.We could define our own objects for our custom stories on facebook.for example we could take pintrest application where PIN is action and and post is the object which is important part of the representing data!

my example :

i have choosen Answer as object and Find as action .I have attended many online forum treasure hunt were we could login using facebook and they could post on our timeline after finishing each round!So lets now define a feed that can improve representation of post using custom stories and could create lot of user interaction.


simple custom story from my application!

Working with Graph API Explorer(debugger):

now to check the post with the help of GRAPH API EXPLORER.just click on the GET CODE in stories and it shows variety of options such as Create,update,delete,retrieve for platform such as Http,PHP SDK,Android,I-OS and javascript SDK.

1) select the HTTP platform and click on the Address given it leads to open the Graph Api explorer where we could debug the url and recieve data from Facebook server using Graph API.try the other platforms also!(i have not yet tried on android/i-os)

2) Just submit the url with POST method and important thing here is me/{APP_Namespace}:{story_action} where we are going to apply the post to our timeline activity.After submiting we could see numeric value on click it we could see the post details.

now visit your timeline ->Activity log you may find your activity as sample data and it doesnt goes live to the friends until the custom story is approved by facebook team! for the application you have created.

additional options to provide users to add message,tags,places etc while posting custom stories so enable it in Action centre at below.
options under action tab!


submit your custom story action for review:

under status and review option you must submit the custom story with lot of restriction made by facebook since to enhance the quality of sharing on facebook and giving clear mind picture if the post produce by the third party apps on facebook that never correlates with native facebook applications and makes the user to experience the real life posts on facebook which are made by developer and could integrate their website with facebook for social traffic and support.

1) click start submission!
before that every developer must know the settings before applying for review in facebook. Each app on facebook must have a LOGO image and have a detailed description about the application for the users to know about your application.
overcome this error by adding necessary details!

2)you must have flow of data and working of your post with screen shot with minimum of 3 photos 
3) a detailed description about working of your custom story details and working of applications and uses of it.
4)once again submit 4 different types of snapshot of your post on facebook that are made using platforms!
5)and then submit for review and be free and have a cup of coffee aside.after three days facebook team approaches you about your status and describes what to be done.

assume that if they have given authorization then you can configure your application properly and then work with graph API calls to update in Facebook.there are lot of rules and regulations using custom stories via graph api login !I will explain how to work after getting authorization for custom stories in my next post!

if you could find errors!report the bug as comments or mail me! share is care!

creating facebook custom stories for facebook application - learn more @i-visionblog.com

we would be fascinated in viewing the status updates,photo updates and as well as many actions that are taking place inside the Facebook.using facebook application we could create custom stories and could be posted inside facebook using such custom stories.Recently i was amazed while using Pintrest and their posts on facebook activity named as pinning action on their wall.This lead me to learn more about Graph API. and posting custom story creation.I was wandering around google for tutorials but facebook developers & stackoverflow gave me brilliant docs to follow and build the custom-stories for facebook application.

procedure:

first of all for all developers must register in the developer about their new app for any platform provided facebook.it may either windows,android,facebook app,website application,i-os application or it may be a game running on facebook canvas.register with correct URL, domain name, and provide with Developer e-mail.

1)Now go to Graph API side tab listed in left column and click that link.
2)You will be showing with Create new stories (custom).


3)Define new story with action and object.
let us see some terms about action and object below.

action: 

action is something you do on facebook and represent the post and provide a view to the friends and you as post in timeline as well as news-feed. For example SHARE is action made by the user and they are represented as post in timeline and we could post in friends timeline.

object:

object is something which is shared,added or done something on facebook.They are things and important part of the post.We could define our own objects for our custom stories on facebook.for example we could take pintrest application where PIN is action and and post is the object which is important part of the representing data!

my example :

i have choosen Answer as object and Find as action .I have attended many online forum treasure hunt were we could login using facebook and they could post on our timeline after finishing each round!So lets now define a feed that can improve representation of post using custom stories and could create lot of user interaction.

simple custom story from my application!

Working with Graph API Explorer(debugger):

now to check the post with the help of GRAPH API EXPLORER.just click on the GET CODE in stories and it shows variety of options such as Create,update,delete,retrieve for platform such as Http,PHP SDK,Android,I-OS and javascript SDK.

1) select the HTTP platform and click on the Address given it leads to open the Graph Api explorer where we could debug the url and recieve data from Facebook server using Graph API.try the other platforms also!(i have not yet tried on android/i-os)

2) Just submit the url with POST method and important thing here is me/{APP_Namespace}:{story_action} where we are going to apply the post to our timeline activity.After submiting we could see numeric value on click it we could see the post details.

now visit your timeline ->Activity log you may find your activity as sample data and it doesnt goes live to the friends until the custom story is approved by facebook team! for the application you have created.

additional options to provide users to add message,tags,places etc while posting custom stories so enable it in Action centre at below.
options under action tab!


submit your custom story action for review:

under status and review option you must submit the custom story with lot of restriction made by facebook since to enhance the quality of sharing on facebook and giving clear mind picture if the post produce by the third party apps on facebook that never correlates with native facebook applications and makes the user to experience the real life posts on facebook which are made by developer and could integrate their website with facebook for social traffic and support.

1) click start submission!
before that every developer must know the settings before applying for review in facebook. Each app on facebook must have a LOGO image and have a detailed description about the application for the users to know about your application.
overcome this error by adding necessary details!

2)you must have flow of data and working of your post with screen shot with minimum of 3 photos 
3) a detailed description about working of your custom story details and working of applications and uses of it.
4)once again submit 4 different types of snapshot of your post on facebook that are made using platforms!
5)and then submit for review and be free and have a cup of coffee aside.after three days facebook team approaches you about your status and describes what to be done.

assume that if they have given authorization then you can configure your application properly and then work with graph API calls to update in Facebook.there are lot of rules and regulations using custom stories via graph api login !I will explain how to work after getting authorization for custom stories in my next post!

if you could find errors!report the bug as comments or mail me! share is care!

Tuesday, 11 March 2014

Android Stepping into Space - Post snippet by @nancy.joslin

android stepping into space- i-visionblog.com
We use Smartphone for many purposes but some minds planned to land it in space and they achieved it.
An ongoing project of NASA, Phonesat made their goal successful. Phonesat is a nano-satellite which uses Smartphone and run on android platforms. This idea was suggested in order to reduce the cost of the satellites. This android satellite is launched into the lower orbit of the earth.
Phonesat was developed for the first time in 2009 at NASA Ames Research Center in Moffett field, California. Various versions are being developed and ready to launch. They are launched as test samples now.

Advantages of this phonesat is that they have faster CPU than the other satellites, one or two cameras for capturing images of earth and space, rotation sensors to detect and orient the satellite , GPS receiver to receive commands, radios to send images .It uses Li-Ion batteries (Lithium ions batteries).

PHONESAT 1.0:

Phonesat 1.0 is the first nano-satellite launched into the low earth orbit. It used Nexus One (Smartphone from HTC & Google) which uses android 2.3.3 operating systems. This was designed with three prototypes at a cost of $3500 for each prototype .This satellite runs in 12 Li-Ion batteries .They had no solar panels. It is approximately 10x10x10cm (4 inch) cube.
                The mission of this phonesat 1.0 is to obtain digital images of earth and space through the camera. This satellite is capable of staying alive for short period in space .The images and satellite health were sent as radio signals via inbuilt radio.This nanosatellite was tested under various conditions in various environments like thermal-vacuum chamber, alpha and beta radiations, vibration and shock tables, high altitude balloons. Phonesat 1.0 was named as GRAHAM and next was named as BELL with Iridium transceiver mounted at one end to receive and send information.

PHONESAT 2.0

Phonesat 2.0 uses Nexus s (from Samsung) which runs on Google android 2.3.3 platform. It has solar panels, 4 Li-Ion batteries, two ways S-band radio to communicate with earth and GPS receiver.ALEXANDER is the name of this satellite, it is also called as Phonesat 2.0 beta, phonesat v2a. This satellite sends packets over amateur radio at 437.4 MHz . This is programmed in such a way that when the packets are not sent it reboots the phone.

PHONESAT 2.4

Phonesat 2.4 also uses Nexus s and android version 2.3.3. It uses 2ways-band radio and it has super control over the orientation of the phone. The Smartphone works as the computing unit and its camera observes the earth while its sensors senses and orient the satellite.
ANTARES 110 launch vehicle on 21 April 2013 carried two phonesat 1.0(GRAHAM and BELL) and one phobesat 2.0(ALEXANDER) and set them in the orbits. It was alive for 2 weeks in space and images sent by phonesat are below here .

 (a) Picture of earth sent by BELL. 

 (b) Picture of earth sent by GRAHAM.









MINOTAUR LORS-3 launch vechile carried phonesat 2.4 and Phonesat 2.5 is being developed and NASA will launch very soon.
author info:

Author       : Nancy joslin , Dharshini and shivaranjani

contact us : visit our facebook fan page i-visionblog and feel free to comment below.

Monday, 3 March 2014

reCAPTCHA Library for PHP - Learnmore @i-visionblog.com

The world is very competitive and every one tries to uphold the growth of others or promote their contents through SPAM E-mail,comments and through various aspects.So,let us see how to prevent SPAM submissions by using reCAPTCHA to validate user input and proving that user is a human being and not a ROBOT.This generally used to prevent users to make spam on site and increase duplication of data.Hope this technique may control to some extent because human become monotonous to such validation on reading the real life image and answer it in correct manner.


download library  -  Live DEMO 


First Register your DOMAIN and get your unique private & public Key.visit here to register

after registration try to get the the public and private.

then now let us set up a form for submission and try to reduce the spam actions that are over thrown on your form.

PHP & HTML code:



<html>
  <body>
    <form action="" method="post">
<?php

require_once('recaptchalib.php');

// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = "YOUR_PUBLIC_KEY";
$privatekey = "YOUR_PRIVATE_KEY";

# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;


if ($_POST["recaptcha_response_field"]) {
        $resp = recaptcha_check_answer ($privatekey,
                                        $_SERVER["REMOTE_ADDR"],
                                        $_POST["recaptcha_challenge_field"],
                                        $_POST["recaptcha_response_field"]);

        if ($resp->is_valid) {
                echo "You got it!";
#REST OF YOUR CODE HERE TO UPDATE IN DATABASE OR VARIOUS OPTIONS TO PERFORM
        } else {
                # set the error code so that we can display it
                $error = $resp->error;
        }
}
echo recaptcha_get_html($publickey, $error);
?>
    <br/>
    <input type="submit" value="submit" />
    </form>
  </body></html>

the above code include recaptchalib.php file in your download folder,just include it in the form to manage the spam.this form automatically detects the error and process the form accordingly.you can add the check up in the another file instead of same file in PHP.

you can customize the Recaptcha theme also- read here

if any bugs report as comments and feel free to share and prevent spam better using google web services.