github.com/line/line-bot-sdk-go/v7@v7.21.0/examples/insight_helper/main.go (about) 1 // Copyright 2019 LINE Corporation 2 // 3 // LINE Corporation licenses this file to you under the Apache License, 4 // version 2.0 (the "License"); you may not use this file except in compliance 5 // with the License. You may obtain a copy of the License at: 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations 13 // under the License. 14 15 package main 16 17 import ( 18 "flag" 19 "log" 20 "os" 21 22 "github.com/line/line-bot-sdk-go/v7/linebot" 23 ) 24 25 func main() { 26 var ( 27 mode = flag.String("mode", "reply", "mode of insight helper [messages|followers|demographics]") 28 date = flag.String("date", "", "date the messages were sent, format 'yyyyMMdd'") 29 ) 30 flag.Parse() 31 bot, err := linebot.New( 32 os.Getenv("CHANNEL_SECRET"), 33 os.Getenv("CHANNEL_TOKEN"), 34 ) 35 if err != nil { 36 log.Fatal(err) 37 } 38 39 switch *mode { 40 case "messages": 41 res, err := bot.GetNumberMessagesDelivery(*date).Do() 42 if err != nil { 43 log.Fatal(err) 44 } 45 log.Printf("%v", res) 46 case "followers": 47 res, err := bot.GetNumberFollowers(*date).Do() 48 if err != nil { 49 log.Fatal(err) 50 } 51 log.Printf("%v", res) 52 case "demographics": 53 res, err := bot.GetFriendDemographics().Do() 54 if err != nil { 55 log.Fatal(err) 56 } 57 log.Printf("%v", res) 58 59 default: 60 log.Fatal("implement me") 61 } 62 }