Update medium_client.go

This commit is contained in:
mycodedoesnotcompile2 2025-12-13 12:26:05 +00:00 committed by GitHub
parent f3beb86ec1
commit 2965aeb592
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,7 @@ import (
"os" "os"
"strings" "strings"
"net/url" "net/url"
"crypto/tls"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
@ -36,7 +37,7 @@ func PostData(postId string) (*entities.MediumResponse, error) {
payload := strings.NewReader(fmt.Sprintf("{\"query\":\"query {\\n post(id: \\\"%s\\\") {\\n title\\n createdAt\\n creator {\\n id\\n name\\n }\\n content {\\n bodyModel {\\n paragraphs {\\n name\\n text\\n type\\n href\\n layout\\n markups {\\n title\\n type\\n href\\n userId\\n start\\n end\\n anchorType\\n }\\n iframe {\\n mediaResource {\\n href\\n iframeSrc\\n iframeWidth\\n iframeHeight\\n }\\n }\\n metadata {\\n id\\n originalWidth\\n originalHeight\\n }\\n }\\n }\\n }\\n }\\n }\",\"variables\":{}}", postId)) payload := strings.NewReader(fmt.Sprintf("{\"query\":\"query {\\n post(id: \\\"%s\\\") {\\n title\\n createdAt\\n creator {\\n id\\n name\\n }\\n content {\\n bodyModel {\\n paragraphs {\\n name\\n text\\n type\\n href\\n layout\\n markups {\\n title\\n type\\n href\\n userId\\n start\\n end\\n anchorType\\n }\\n iframe {\\n mediaResource {\\n href\\n iframeSrc\\n iframeWidth\\n iframeHeight\\n }\\n }\\n metadata {\\n id\\n originalWidth\\n originalHeight\\n }\\n }\\n }\\n }\\n }\\n }\",\"variables\":{}}", postId))
client := &http.Client{}
if config.Conf.Proxy != "" { if config.Conf.Proxy != "" {
proxyURL, err := url.Parse(config.Conf.Proxy) proxyURL, err := url.Parse(config.Conf.Proxy)
@ -46,10 +47,15 @@ func PostData(postId string) (*entities.MediumResponse, error) {
client := &http.Client{ client := &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
Proxy: http.ProxyURL(proxyURL), Proxy: http.ProxyURL(proxyURL),
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true, // Skip TLS verification
}, },
} }
log.Printf("Using proxy: %s", config.Conf.Proxy) log.Printf("Using proxy: %s", config.Conf.Proxy)
} }
else {
client := &http.Client{}
}
req, err := http.NewRequest(method, urlreq, payload) req, err := http.NewRequest(method, urlreq, payload)
if err != nil { if err != nil {