Use API token with FA Utility API.
This commit is contained in:
parent
fb1e8fb9ce
commit
bc135494d6
|
@ -15,6 +15,7 @@ Items either need to be set in config.json as lowercase or environment variables
|
|||
* `TWITTER_CONSUMER_KEY` - Twitter application consumer access key
|
||||
* `TWITTER_SECRET_KEY` - Twitter application consumer secret key
|
||||
* `DB_DIR` - Folder to store app.db in, will be created if it does not exist. Docker defaults to `/app/db`.
|
||||
* `FAUTIL_KEY` - API token for https://fa.huefox.com/
|
||||
|
||||
If using Twitter credentials from users, the `DB_DIR` folder must be persistent.
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ func (cmd sourceCommand) Execute(message tgbotapi.Message) error {
|
|||
return err
|
||||
}
|
||||
req.Header.Set("Content-Type", w.FormDataContentType())
|
||||
req.Header.Set("X-Api-Key", cmd.Config.Get("fautil_key").(string))
|
||||
|
||||
resp, err = http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
|
|
|
@ -24,7 +24,8 @@ type imageURLResult struct {
|
|||
}
|
||||
|
||||
type fa struct {
|
||||
cookies []*http.Cookie
|
||||
cookies []*http.Cookie
|
||||
fautilKey string
|
||||
}
|
||||
|
||||
func (fa) Name() string {
|
||||
|
@ -42,6 +43,7 @@ func (f *fa) loadConfig(finch *finch.Finch) {
|
|||
}
|
||||
|
||||
f.cookies = cookies
|
||||
f.fautilKey = finch.Config.Get("fautil_key").(string)
|
||||
}
|
||||
|
||||
func (fa) IsSupportedURL(url string) bool {
|
||||
|
@ -63,7 +65,10 @@ func (f fa) handleDirectLink(postURL string) ([]PostInfo, error) {
|
|||
u, _ := url.Parse(imageURLEndpoint)
|
||||
u.RawQuery = v.Encode()
|
||||
|
||||
resp, err := http.Get(u.String())
|
||||
req, _ := http.NewRequest("GET", u.String(), nil)
|
||||
req.Header.Set("X-Api-Key", f.fautilKey)
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue