github.com/line/line-bot-sdk-go/v7@v7.21.0/linebot/example_test.go (about) 1 // Copyright 2016 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 linebot_test 16 17 import ( 18 "fmt" 19 "os" 20 21 "github.com/line/line-bot-sdk-go/v7/linebot" 22 ) 23 24 func ExampleIDsScanner() { 25 bot, err := linebot.New("secret", "token") 26 if err != nil { 27 fmt.Fprintln(os.Stderr, "linebot.New:", err) 28 } 29 s := bot.GetGroupMemberIDs("cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "").NewScanner() 30 for s.Scan() { 31 fmt.Fprintln(os.Stdout, s.ID()) 32 } 33 if err := s.Err(); err != nil { 34 fmt.Fprintln(os.Stderr, "GetGroupMemberIDs:", err) 35 } 36 } 37 38 func ExampleUnmarshalFlexMessageJSON() { 39 container, err := linebot.UnmarshalFlexMessageJSON([]byte(`{ 40 "type": "bubble", 41 "body": { 42 "type": "box", 43 "layout": "vertical", 44 "contents": [ 45 { 46 "type": "text", 47 "text": "hello" 48 }, 49 { 50 "type": "text", 51 "text": "world" 52 } 53 ] 54 } 55 }`)) 56 if err != nil { 57 panic(err) 58 } 59 60 linebot.NewFlexMessage("alt text", container) 61 }