Skip to content

Instantly share code, notes, and snippets.

Evan Lin kkdai

Block or report user

Report or block kkdai

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View liff_ isApiAvailable.js
if (liff.isApiAvailable('shareTargetPicker')) {
liff.shareTargetPicker([{
type: "text",
text: message
}])
.then(
//alert("ShareTargetPicker was launched")
).catch(function(res) {
//alert("Failed to launch ShareTargetPicker")
})
View icon.go
//If user already select the sender feedback, prepare user nick name and icon here.
switch {
case strings.EqualFold(message.Text, "Brown"):
sendr = linebot.NewSender("Brown", BrownImage)
case strings.EqualFold(message.Text, "Cony"):
sendr = linebot.NewSender("Cony", ConyImage)
case strings.EqualFold(message.Text, "Sally"):
sendr = linebot.NewSender("Sally", SallyImage)
default:
//User input other than our provide range, notify user by quick reply.
View LINE_FriendsList.go
//For LINE Friends images, please refer to https://developers.line.biz/media/messaging-api/sticker_list.pdf
const (
BrownImage string = "https://stickershop.line-scdn.net/stickershop/v1/sticker/52002734/iPhone/sticker_key@2x.png"
ConyImage string = "https://stickershop.line-scdn.net/stickershop/v1/sticker/52002735/iPhone/sticker_key@2x.png"
SallyImage string = "https://stickershop.line-scdn.net/stickershop/v1/sticker/52002736/iPhone/sticker_key@2x.png"
)
View CookiesJQuery.go
package main
import (
"fmt"
"github.com/PuerkitoBio/goquery"
)
func parseWebUrl(url string) {
resp := getResponseWithCookie(target)
doc, err := goquery.NewDocumentFromResponse(resp)
View CookiesJQuery.go
package main
import (
"fmt"
"github.com/PuerkitoBio/goquery"
)
func parseWebUrl(url string) {
resp := getResponseWithCookie(target)
doc, err := goquery.NewDocumentFromResponse(resp)
View httpcookie.go
func HTTPwithCookies(url, ds_user_id, sessionid, csrftoken string) (b []byte, err error) {
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return
}
req.AddCookie(&http.Cookie{Name: "ds_user_id", Value: ds_user_id})
req.AddCookie(&http.Cookie{Name: "sessionid", Value: sessionid})
req.AddCookie(&http.Cookie{Name: "csrftoken", Value: csrftoken})
View jqueryProblem.go
package main
import (
"fmt"
"github.com/PuerkitoBio/goquery"
)
func parseWebUrl(url string) {
doc, err = goquery.NewDocument(url)
if err != nil {
View getYoutubeVideoURL.go
func getVideoURL(data url.Values) (string, error) {
streamMap, ok := data["url_encoded_fmt_stream_map"]
if !ok {
err = errors.New(fmt.Sprint("no stream map found in the server's answer"))
return err
}
// read each stream
streamsList := strings.Split(streamMap[0], ",")
View getVideoTitleAuthor.go
func getVideoTitleAuthor(in url.Values) (string, string) {
playResponse, ok := in["player_response"]
if !ok {
return "", ""
}
personMap := make(map[string]interface{})
if err := json.Unmarshal([]byte(playResponse[0]), &personMap); err != nil {
panic(err)
}
View parseVideoInfo.go
func parseVideoInfo(videoInfo string) error {
answer, err := url.ParseQuery(videoInfo)
if err != nil {
return err
}
status, ok := answer["status"]
if !ok {
err = fmt.Errorf("no response status found in the server's answer")
return err
You can’t perform that action at this time.