Tuesday, December 26, 2017

How to create bitly URL using bitly API in PHP?[solved]

Hey All,

Please follow below step to create your long URL to bitly URL as short.
Step1 : Get your long URL form DB as alias
---------------------------------------------------------------------------------------------------
$db     = JFactory::getDbo();
$query  = $db->getQuery(true);
$query->select("id, prod_name, urlalias, bitlyUrl,builderName");
$query->from("#__products");
$query->where($db->quoteName('urlalias').' != "" ' );//http://bit.ly/
$query->where($db->quoteName('bitlyUrl').' ="" OR '.$db->quoteName('bitlyUrl').' = "http://bit.ly/" '  );
$db->setQuery($query);
$resultUrl= $db->loadAssocList();
-----------------------------------------------------------------------------------------------------
$rootURL="https://phptechnicalgroups.blogspot.in"
foreach( $resultUrl as $geturl ){

echo $url = $rootURL.'/'.$geturl['urlalias'];
echo "<br>";
$referralUrl = make_bitly_url($url,'bikashranjan','XXXXXXXXXXXXXX','xml','2.0.1');
echo $sql = "Update ".$db->quoteName('#__products')." SET ".$db->quoteName('bitlyUrl')." = ".$db->quote($referralUrl)." WHERE    ".$db->quoteName('id')." = ".$db->quote($mValue['id']);
echo "<br><br>";
$db->setQuery($sql);
$db->query();
}

Step 2: Create developer account on bit http://dev.bitly.com and get the login user and app key
---------------------------------------------------------------------------------------------------------
//Step 3: Create a function within the function call bitly API follow below function
function make_bitly_url($url,$login,$appkey,$format = 'xml',$version = '2.0.1'){
//create the URL
$bitly = 'http://api.bit.ly/shorten?version='.$version.'&longUrl='.urlencode($url).'&login='.$login.'&apiKey='.$appkey.'&format='.$format;
//get the url
//could also use cURL here
$response = file_get_contents($bitly);
//print_r($response);
//parse depending on desired format
if(strtolower($format) == 'json')
{
$json = @json_decode($response,true);
return $json['results'][$url]['shortUrl'];
}
else //xml
{
$xml = simplexml_load_string($response);
return 'http://bit.ly/'.$xml->results->nodeKeyVal->hash;
       }
}

Hopefully it will help you :)

Thursday, December 7, 2017

Anchor tag slow scroll using jquery open direct url

below Jquery code should work for scroll anchor tag from URL

jQuery(function() {
  jQuery('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = jQuery(this.hash);
      target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        jQuery('html,body').animate({
          scrollTop: target.offset().top - 125 //offsets for fixed header
        }, 1000);
        return false;
      }
    }
  });
  //Executed on page load with URL containing an anchor tag.
  if(jQuery(location.href.split("#")[1])) {
      var target = jQuery('#'+location.href.split("#")[1]);
      if (target.length) {
        jQuery('html,body').animate({
          scrollTop: target.offset().top - 140 //offset height of header here too.
        }, 1000);
        return false;
      }
    }
});

Friday, October 27, 2017

What are git commands are essential for developer?[SOLVED]

Hey Guys,

I am Bikash Ranjan Nayak , if some one confusion in GIT command as a developer . I am  trying to explore you what are these command in git for regular wise required.


Before you use the git command in terminal just to confirm the configure for your user name and email address from IT team who have done it.
Note : it is one time required when you start first terminal for git.

1.Once you confirmed your user name and email which was create for git access user by IT team.

Command terminal will ask you the credentials like below
git config --global user.bikash "Bikash ranajn nayak"
git config --global user.nayakr.bikash@gmail.com
2.Clone live application from repository in your local
git clone git+ssh://bikash@127.0.0.1/home/repository/applicationName

3.Created branches by IT team Like : Dev ,Stage,master(As live App) server.
  As a developer can checkout add,commit,push within the Dev barnch
 Lets start how developer can doing while developing.

Need to follow below step to push you updated code into dev branch.

Step 1 : Run command in terminal before you start work on you application
git checkout <Dev>
Step 2: Take update from dev branch using below command
git pull origin <Dev>
Step 3: Create your task related branch within dev branch
        git checkout -b <features/bikash_RequestNo_date>

Step 4: before you start work, please ensure in which branch you are in . run the below command to know which branch you are in , current branch will highlited as green.
git branch -a

Step 5: If you are in your branch then start your work now , after completed your updates in page or created add new file.

if you added new file then first run below command.
        git add .
Step 6: Now commit your branch in local
         git commit -am <"message write what you have done for understing">

Step 7: Now we need to upload our updated code into Dev server.
git checkout <Dev>
Step 8: please take update from dev , other resource which they have done
        git pull origin <dev>

Step 9 : Then mere your branch into dev which you have earlier you worked on
git merge --no-commit <features/bikash_RequestNo_date>
Step 10 :Now commit your update  on dev server
git commit -am <"message write what you have done for under sting">
Finally upload into dev server using below command
git push origin <dev>
Now come back to you branch or create new branch for new task


Hope you are achieved those git commands as developer end