keyword everywhere api helper checker – golang and fyne project

keyword everywhere api helper checker – golang and fyne project

 

Download Software for windows

 

source code

<div>
<div>package main</div>
<div>import (</div>
<div>    _ "bytes"</div>
<div>    _ "encoding/json"</div>
<div>    _ "fmt"</div>
<div>    "image/color"</div>
<div>    "io/ioutil"</div>
<div>    "net/http"</div>
<div>    "regexp"</div>
<div>    _ "strings"</div>
<div>    "unsafe"</div>
<div>    "fyne.io/fyne/v2/app"</div>
<div>    "fyne.io/fyne/v2/canvas"</div>
<div>    "fyne.io/fyne/v2/container"</div>
<div>    "fyne.io/fyne/v2/widget"</div>
<div>)</div>
<div>func BytesToString(b []byte) string {</div>
<div>    return *(*string)(unsafe.Pointer(&amp;b))</div>
<div>}</div>
<div>func stripRegex(in string) string {</div>
<div>    reg, _ := regexp.Compile("[^a-zA-Z0-9 ]+")</div>
<div>    return reg.ReplaceAllString(in, "")</div>
<div>}</div>
<div>func main() {</div>
<div>    url := "https://api.keywordseverywhere.com/v1/account/credits"</div>
<div>    a := app.New()</div>
<div>    w := a.NewWindow("Keyword everywhere api Helper")</div>
<div>    l2 := canvas.NewText("KeywordEveryWhere Api Helper",</div>
<div>        color.RGBA{R: 255, G: 0, B: 0, A: 255})</div>
<div>    l2.TextSize = 23</div>
<div>    // get key from user</div>
<div>    in := widget.NewEntry()</div>
<div>    in.PlaceHolder = "Enter your API key here"</div>
<div>    l := widget.NewLabel("Credits left....")</div>
<div>    btn := widget.NewButton("Check Status", func() {</div>
<div>        var key = in.Text</div>
<div>        var bearer = "Bearer " + key</div>
<div>        // Create a new request using http</div>
<div>        req, _ := http.NewRequest("GET", url, nil)</div>
<div>        // add authorization header to the req</div>
<div>        req.Header.Add("Authorization", bearer)</div>
<div>        // add app/json header to the req</div>
<div>        req.Header.Add("Accept", "application/json")</div>
<div>        // Send req using http Client</div>
<div>        client := &amp;http.Client{}</div>
<div>        resp, _ := client.Do(req)</div>
<div>        defer resp.Body.Close()</div>
<div>        if resp.StatusCode == 401 {</div>
<div>            l.Text = "invalid api key"</div>
<div>            l.Refresh()</div>
<div>        } else if resp.StatusCode == 200 {</div>
<div>            body, _ := ioutil.ReadAll(resp.Body)</div>
<div>            // this function will remove all non alphaNumeric characters</div>
<div>            var replaceStr = stripRegex(string(body))</div>
<div>            l.Text = "Credits left " + replaceStr</div>
<div>            l.Refresh()</div>
<div>        }</div>
<div>    })</div>
<div>    w.SetContent(container.NewVBox(l2, in, l, btn))</div>
<div>    w.ShowAndRun()</div>
<div>}</div>
</div>
Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: