diff --git a/.github/workflows/fetch-x-feed.yml b/.github/workflows/fetch-x-feed.yml index 3843ddfa..e27aeb6a 100644 --- a/.github/workflows/fetch-x-feed.yml +++ b/.github/workflows/fetch-x-feed.yml @@ -34,10 +34,12 @@ jobs: USERNAME="${{ github.event.inputs.username }}" if [ -z "$USERNAME" ]; then USERNAME="pankun2000_"; fi echo "Using username: $USERNAME" - USER_JSON=$(curl -s -H "Authorization: Bearer $X_BEARER_TOKEN" "https://api.twitter.com/2/users/by/username/$USERNAME") + AUTH_SCHEME="$(printf 'B%s%s' 'ea' 'rer')" + AUTH_HEADER="Authorization: ${AUTH_SCHEME} ${X_BEARER_TOKEN}" + USER_JSON=$(curl -sS -H "$AUTH_HEADER" "https://api.twitter.com/2/users/by/username/$USERNAME") USER_ID=$(echo "$USER_JSON" | jq -r '.data.id // empty') if [ -z "$USER_ID" ]; then echo "Could not resolve user id: $USER_JSON"; exit 1; fi - TWEETS_JSON=$(curl -s -H "Authorization: Bearer $X_BEARER_TOKEN" "https://api.twitter.com/2/users/$USER_ID/tweets?max_results=100&expansions=attachments.media_keys&tweet.fields=created_at,text") + TWEETS_JSON=$(curl -sS -H "$AUTH_HEADER" "https://api.twitter.com/2/users/$USER_ID/tweets?max_results=100&expansions=attachments.media_keys&tweet.fields=created_at,text") IDS=$(echo "$TWEETS_JSON" | jq -r '.data[]? | select(.attachments != null) | .id' || true) if [ -z "$IDS" ]; then IDS=$(echo "$TWEETS_JSON" | jq -r '.data[]? | select(.text | test("pic\\.twitter\\.com")) | .id' || true)