DEV Community

Discussion on: Social Media Accounts Shouldn't Be Static! πŸ’ƒπŸ½

Collapse
 
mnlwldr profile image
manuel • Edited

Hi. We had the same idea :) I commented on the other post already.

Here my Golang code to do this :)

package main

import (
    "github.com/ChimeraCoder/anaconda"
    "net/url"
    "strconv"
)

func initAnaconda() *anaconda.TwitterApi {
    return anaconda.NewTwitterApiWithCredentials(
        "ACCESS_TOKEN",
        "ACCESS_TOKEN_SECRET",
        "CONSUMER_KEY",
        "CONSUMER_SECRET")
}

func main() {
    api := initAnaconda()
    params := url.Values{}
    me, err := api.GetSelf(params)
    if err != nil {
        panic(err)
    }
    followers := me.FollowersCount
    name := "YOUR_NAME and the " + strconv.FormatInt(int64(followers), 10) + " followers"
    updateParams := url.Values{}
    updateParams.Set("name", name)
    api.PostAccountUpdateProfile(updateParams)
}
Collapse
 
0xbanana profile image
🍌🍌🍌

Oh cool! I’ve been meaning to learn more golang thank you for sharing this!

Collapse
 
mnlwldr profile image
manuel

I learning Golang in the Moment for fun. It's cool.