this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove twit-link as it's not used

-47
-47
scripts/twit-link.go
··· 1 - /************************* 2 - This is a quick utility designed to take a uri to a tweet and render it as a twitter-looking tweet. 3 - 4 - Author: stahnma 5 - Email: stahnma@websages.com 6 - License: Apache 2 7 - 8 - Notes: 9 - Takes a uri like https://twitter.com/stahnma/status/452133159329476608 10 - *************************/ 11 - package main 12 - 13 - import "encoding/json" 14 - import "fmt" 15 - import "io/ioutil" 16 - import "net/http" 17 - import "regexp" 18 - import "os" 19 - import "strings" 20 - 21 - func main() { 22 - if len(os.Args) <= 1 { 23 - // No argument passed 24 - os.Exit(1) 25 - } 26 - input := os.Args[1] 27 - matched, err := regexp.MatchString("twitter.com*", input) 28 - if matched == false { 29 - // Not a twitter uri 30 - os.Exit(2) 31 - } 32 - parts := strings.Split(input, "/") 33 - id := parts[len(parts)-1] 34 - var f interface{} 35 - 36 - uri := "https://api.twitter.com/1/statuses/oembed.json?id=" + id 37 - resp, err := http.Get(uri) 38 - if err != nil { 39 - fmt.Println("error:", err) 40 - } 41 - defer resp.Body.Close() 42 - body, err := ioutil.ReadAll(resp.Body) 43 - err = json.Unmarshal(body, &f) 44 - m := f.(map[string]interface{}) 45 - html2 := m["html"].(string) 46 - fmt.Println(html2) 47 - }