Posts

Showing posts from October, 2020

Logic Building Episode 1 : Generate N digit random number based on input

Problem Statement: Write a function that generates an N digit random number based on the N input. Input: N=5 Output: XXXXX (N digit random number) Input: N= 2 Output: XX Give try yourself, before look at the solution and share your solution in the comment. package main import ( " fmt " " math/rand " " strconv " " strings " " time " ) // random func will generate a random digit number based on param. func random ( param int ) { rand . Seed ( time . Now (). UnixNano ()) chars := [] rune ( "0123456789" ) var b strings . Builder for i := 1 ; i <= param ; i ++ { b . WriteRune ( chars [ rand . Intn ( len ( chars ))]) } str := b . String () i , err := strconv . Atoi ( str ) if err != nil { fmt . Println ( "error while convert" ) } fmt . Println ( i ) } // Driver func main () { random ( 5 ) // N = 5 } Output: λ ra

LinkedIn API implementation in Your App - OAuth and Post Share.

Image
In this part, we will see How to call a LinkedIn API and get a Linkedin OAuth Access Token and Share a post, will test using curl and postman. In the next part, we will see how to implement that in the Go code.  1. Get a Linkedin OAuth Access Token Prerequisites: LinkedIn Account curl 1. Client Registration go to:  https://www.linkedin.com/developers/apps Click on "create new" or use this direct link: https://www.linkedin.com/developers/apps/new Verify Company What you need: redirectURI =  URLENCODE(redirectURI) =  clientId =  clientSecret  =  clientID = 78.................vl clientSecret = I2.................n9kW redirectURI = https://www.google.com/ URLENCODE (redirectURI) = https%3A%2F%2F www.google.com%2F (URLENCODE part of url for curl param) encode using ( https://www.urlencoder.org/ ) Authorization Endpoint (Browser) What you need: scope = r_liteprofile “https://www.linkedin.com/oauth/v2/authorization?response_type=code&state=987654321&scope=scope&clien