Friday, February 14, 2014

Change your Facebook Username

This is a little hacky type of method but it works

Step 1 
  • Go to account settings from your
  • Click on ‘Security’
  • Then click the option ‘Deactivate your account.’
  • Give explanation as “Its temporary”.

Step 2
  • Then log in again with your email and password.
  • Done
  • Your account is re-activated.
Step 3
  • Go to account settings from the button on top right.
  • Edit username.
  • Done. Your account username is changed.

Friday, June 28, 2013

Create QR code generator using php-curl


    $url = "https://chart.googleapis.com/chart?";
    $strPost = "cht=qr&chs=177x177&chl=http://opendummies.blogspot.in/";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    // curl_setopt($ch, CURLOPT_PROXY, $proxy);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_HTTPGET,1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: image/jpeg"));
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $strPost); // add POST fields
    curl_setopt($ch, CURLOPT_POST, 1);
    header('Content-Type: image/jpeg');
    echo $result = curl_exec($ch);
    curl_close($ch);
    

output:

Tuesday, June 25, 2013

URL shortner using Bitly - PHP

For creating a shorten url you need to create an account in the following link:

http://dev.bitly.com/my_apps.html

Now go to 

https://bitly.com/a/oauth_apps 

Here you need to create a accesstoken if you are creating for the first time it prompts for the password.

Then you get a alpha numeric value as accesstoken section.


Now use the following Code:

    $url = "https://api-ssl.bitly.com/v3/shorten";
    $strPost = "longUrl=http%3A%2F%2Fgoogle.com%2F&   access_token=YOUR ACCESSTOKEN";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    // curl_setopt($ch, CURLOPT_PROXY, $proxy);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_HTTPGET,1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/json"));
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $strPost); // add POST fields
    curl_setopt($ch, CURLOPT_POST, 1);
    $result = curl_exec($ch);
    var_dump($result);
    curl_close($ch);


The output of this file will return a json string
 
{
    "status_code" : 200,
    "status_txt" : "OK",
    "data" : {
        "long_url" : "http:\/\/google.com\/",
        "url" : "http:\/\/bit.ly\/14UO8lv",
        "hash" : "14UO8lv",
        "global_hash" : "900913",
        "new_hash" : 1
    }
}



NOTE
The bitly code is to be used for personal accounts cannot be used for Enterprise use if you want to use it for Enterprise you need to request them for the details but this code even works for that Code too.

Google shorten URL - a Simple CURL script


    $url = "https://www.googleapis.com/urlshortener/v1/url";
    $strPost = '{"longUrl": "YOUR LONG URL"}';
 
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    //if your are using proxy url use proxy setting
    // curl_setopt($ch, CURLOPT_PROXY, $proxy);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_HTTPGET,1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/json")); //since i am requesting json response
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $strPost); // add POST fields
    curl_setopt($ch, CURLOPT_POST, 1);
    $result = curl_exec($ch);
    var_dump($result);
    curl_close($ch);
    exit;

If you dont want to use the google url shortner want to create your own


check it here :
http://opendummies.blogspot.in/2014/07/creating-url-shortner.html

Thursday, December 6, 2012

Convert First letter a string to capital

Here is the function which is used to convert all the first letters of the name to capital Letters. 

 This idea of creating this  function is inspired with the words of my colleague   Kamal Relwani

Sunday, November 4, 2012

How to create a facebook add friend request

Using JavaScript :
 Things Required all u need to do i call
  1. Call FB.init Method -
    FB.init({  appId  : 'YOUR_APP_ID',  frictionlessRequests : true });
  2. To send request for purticular friends
    1. function sendRequestToRecipients(){ FB.ui ({method: 'apprequests', message: 'My Request', to: '12345,23456' }, requestCallback); }
  1.  To send request for all friends
    1. function sendRequestViaMultiFriendSelector() {
        FB.ui({method: 'apprequests',
          message: 'My  Request'
        }, callbackfunction());
      }
       callbackfunction(response){
       alert(response);
      }
  

Wednesday, October 3, 2012

Create a Date Drop down

Creating a Date year and Date drop down which is validated based on leap year and date 

Here is the code please add jquery script tag before you include the code


 function fnDate(){
try{
for(var i=1950;i<=2009;i++){
jq("#dobyy").append("<option value="+i+">"+i+"</option>");
}
for(var i=1;i<=12;i++){
jq("#dobmm").append("<option value="+i+">"+i+"</option>");
}

var month = '';
var year = '';
jq("#dobmm").change(function(){
month = jq("#dobmm").val();
year = jq("#dobyy").val();
var aOddMnth = ["1","3","5","7","8","10","12"];
var aEvnMnth = ["4","6","9","11"];
jq("#dobdd").html("<select name=\"dobdd\" id=\"dobdd\" title=\"1\" style=\"width:84px;\"><option value=\"\">Day</option></select>&nbsp;&nbsp;&nbsp;&nbsp;");
if(month > 0){
if(month == "2"){
if(year%4 == 0){
for(var i=1;i<=29;i++){
jq("#dobdd").append("<option value="+i+">"+i+"</option>");
}
}else{
for(var i=1;i<=28;i++){
jq("#dobdd").append("<option value="+i+">"+i+"</option>");
}
}
}
if(jq.inArray(month,aOddMnth) != -1){
for(var i=1;i<=31;i++){
jq("#dobdd").append("<option value="+i+">"+i+"</option>");
}
}
if(jq.inArray(month,aEvnMnth) != -1){
for(var i=1;i<=30;i++){
jq("#dobdd").append("<option value="+i+">"+i+"</option>");
}
}
}
});
}catch(e){
alert(e.message)
}
}