-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from juunini/develope
change function "send"
- Loading branch information
Showing
5 changed files
with
35 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,19 @@ | ||
package notify | ||
|
||
import ( | ||
"net/http" | ||
"net/url" | ||
"strings" | ||
) | ||
|
||
// SendImage : send line notify simple text with image | ||
func SendImage(accessToken, message, imageURL string) (err error) { | ||
req, err := http.NewRequest( | ||
"POST", | ||
lineNotifyApiURL, | ||
strings.NewReader(url.Values{ | ||
"message": []string{message}, | ||
"imageThumbnail": []string{imageURL}, | ||
"imageFullsize": []string{imageURL}, | ||
}.Encode()), | ||
) | ||
if err != nil { | ||
return | ||
} | ||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded") | ||
body := strings.NewReader(url.Values{ | ||
"message": []string{message}, | ||
"imageThumbnail": []string{imageURL}, | ||
"imageFullsize": []string{imageURL}, | ||
}.Encode()) | ||
contentType := "application/x-www-form-urlencoded" | ||
|
||
err = sendToLineServer(req, accessToken) | ||
err = sendToLineServer(body, accessToken, contentType) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,17 @@ | ||
package notify | ||
|
||
import ( | ||
"net/http" | ||
"net/url" | ||
"strings" | ||
) | ||
|
||
// SendText : send line notify simple text | ||
func SendText(accessToken, message string) (err error) { | ||
req, err := http.NewRequest( | ||
"POST", | ||
lineNotifyApiURL, | ||
strings.NewReader(url.Values{ | ||
"message": []string{message}, | ||
}.Encode()), | ||
) | ||
if err != nil { | ||
return | ||
} | ||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded") | ||
body := strings.NewReader(url.Values{ | ||
"message": []string{message}, | ||
}.Encode()) | ||
contentType := "application/x-www-form-urlencoded" | ||
|
||
err = sendToLineServer(req, accessToken) | ||
err = sendToLineServer(body, accessToken, contentType) | ||
return | ||
} |