summaryrefslogtreecommitdiff
path: root/internal/platforms/linkedin
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-10-27 17:19:34 +0200
committerPaul Buetow <paul@buetow.org>2024-10-27 17:19:34 +0200
commit3d8935e6456bcfe462bd7735615e9009ef5ff7c6 (patch)
tree342ba25a782d72490b9fa5931685e818a79a2aaf /internal/platforms/linkedin
parente17fa34a36835930a0ec1678e086f450cb9aa620 (diff)
can ask before queueing
Diffstat (limited to 'internal/platforms/linkedin')
-rw-r--r--internal/platforms/linkedin/linkedin.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/internal/platforms/linkedin/linkedin.go b/internal/platforms/linkedin/linkedin.go
index 6646937..75f4693 100644
--- a/internal/platforms/linkedin/linkedin.go
+++ b/internal/platforms/linkedin/linkedin.go
@@ -19,7 +19,10 @@ import (
var errUnauthorized = errors.New("unauthorized access, refresh or create token?")
-const linkedInTimeout = 10 * time.Second
+const (
+ linkedInPostsURL = "https://api.linkedin.com/rest/posts"
+ linkedInTimeout = 10 * time.Second
+)
func Post(ctx context.Context, args config.Args, sizeLimit int, ent entry.Entry) error {
err := post(ctx, args, sizeLimit, ent)
@@ -72,8 +75,6 @@ func post(ctx context.Context, args config.Args, sizeLimit int, ent entry.Entry)
}
func callLinkedInAPI(ctx context.Context, personID, accessToken, content string, prev preview) error {
- const url = "https://api.linkedin.com/rest/posts"
-
post := map[string]interface{}{
"author": fmt.Sprintf("urn:li:person:%s", personID),
"commentary": escapeLinkedInText(content),
@@ -101,7 +102,7 @@ func callLinkedInAPI(ctx context.Context, personID, accessToken, content string,
if err != nil {
return fmt.Errorf("Error encoding JSON:%w", err)
}
- req, err := http.NewRequestWithContext(ctx, "POST", url, bytes.NewBuffer(payload))
+ req, err := http.NewRequestWithContext(ctx, "POST", linkedInPostsURL, bytes.NewBuffer(payload))
if err != nil {
return fmt.Errorf("Error creating request: %w", err)
}