From e00cfe4ddf82f13caa3868274411f9dd387e9645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=91=E3=83=B3=E5=90=9B?= Date: Wed, 16 Sep 2026 11:09:27 +0900 Subject: [PATCH] Refactor Twitter API calls to use auth header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: パン君 --- .github/workflows/fetch-x-feed.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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)