<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Twitter on kenji.blog</title><link>http://kenji.blog/ko/tags/twitter/</link><description>Recent content in Twitter on kenji.blog</description><generator>Hugo -- gohugo.io</generator><language>ko</language><copyright>kenjinote</copyright><lastBuildDate>Sat, 08 Apr 2023 18:48:32 +0900</lastBuildDate><atom:link href="http://kenji.blog/ko/tags/twitter/index.xml" rel="self" type="application/rss+xml"/><item><title>'Twitter API와 Google Colaboratory를 사용하여 트윗하는 방법'</title><link>http://kenji.blog/ko/p/twitter-api%E3%81%A8google-colaboratory%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6tweet%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/</link><pubDate>Sat, 08 Apr 2023 18:48:32 +0900</pubDate><guid>http://kenji.blog/ko/p/twitter-api%E3%81%A8google-colaboratory%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6tweet%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/</guid><description>&lt;img src="http://kenji.blog/p/twitter-api%E3%81%A8google-colaboratory%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6tweet%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img.png" alt="Featured image of post 'Twitter API와 Google Colaboratory를 사용하여 트윗하는 방법'" />&lt;h1 id="필요한-것">필요한 것
&lt;/h1>&lt;ul>
&lt;li>Twitter API&lt;/li>
&lt;li>Twitter API SECRET&lt;/li>
&lt;li>Twitter ACCESS TOKEN&lt;/li>
&lt;li>Twitter ACCESS TOKEN SECRET&lt;/li>
&lt;li>Google 계정&lt;/li>
&lt;/ul>
&lt;p>Twitter API 취득 방법은 참고 사이트를 참조해 주세요.&lt;/p>
&lt;h1 id="api를-사용하여-트윗하는-순서">API를 사용하여 트윗하는 순서
&lt;/h1>&lt;ol>
&lt;li>&lt;a class="link" href="https://colab.research.google.com/" target="_blank" rel="noopener"
>https://colab.research.google.com/&lt;/a> 에 접속&lt;/li>
&lt;li>「파일」→「새 노트 만들기」를 선택&lt;/li>
&lt;li>아래의 코드를 붙여넣고 실행 (실제 각 값은 직접 취득한 것을 사용해 주세요)&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">API_KEY = &amp;#39;9Smu2f2RoLqbVQHQq6n79Z2JW&amp;#39;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">API_SECRET = &amp;#39;uGVRIkLL2l8sRyPv2Lr4mXxXppnQF1isMoRnvktcXCtFgAK2R8&amp;#39;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ACCESS_TOKEN = &amp;#39;0367292979164670705-7hSErDoQbO6fkFtnn5UY0vqpvecy0O&amp;#39;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ACCESS_TOKEN_SECRET = &amp;#39;pUv81U9GVzZirz5g4AxZPHAJ4GpSXnBo8GUcZ1egtjw9q&amp;#39;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ol start="3">
&lt;li>아래의 코드를 붙여넣고 실행&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">import tweepy
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ol start="4">
&lt;li>아래의 코드를 붙여넣고 실행 (API v1.1)&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">auth = tweepy.OAuthHandler(API_KEY, API_SECRET)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">api = tweepy.API(auth)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">api.update_status(&amp;#34;hello&amp;#34;)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>→&lt;code>hello&lt;/code>라는 트윗이 게시됨&lt;/p>
&lt;ol start="5">
&lt;li>아래의 코드를 붙여넣고 실행 (API v2.0)&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">client = tweepy.Client(consumer_key=API_KEY, consumer_secret=API_SECRET, access_token=ACCESS_TOKEN, access_token_secret=ACCESS_TOKEN_SECRET)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">client.create_tweet(text=&amp;#39;hello v2&amp;#39;)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>→&lt;code>hello v2&lt;/code>라는 트윗이 게시됨&lt;/p>
&lt;p>이상&lt;/p>
&lt;h1 id="참고">참고
&lt;/h1>&lt;ul>
&lt;li>&lt;a class="link" href="https://bloomtectec.com/twitter-api-application-procedure/" target="_blank" rel="noopener"
>【2021년 4월 기준】 Twitter API 이용 신청을 사용 용도 예문과 스크린샷으로 철저하게 해설&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="https://bloomtectec.com/use-twitter-api-in-google-colab/" target="_blank" rel="noopener"
>【번거로운 설정 불필요!】 Twitter API 테스트 환경이라면 Google Colaboratory를 추천 【소스 코드도 공유합니다】&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="https://3pysci.com/tweepy-28/" target="_blank" rel="noopener"
>【Tweepy】 Twitter API v2: 트윗, 답글(리플라이), 투표 포함 트윗, 미디어 포함 트윗 (v1.1) [Python]&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>'PaperMod에서 Twitter Card를 설정하는 방법'</title><link>http://kenji.blog/ko/p/papermod%E3%81%A7twitter-card%E3%82%92%E8%A8%AD%E5%AE%9A%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/</link><pubDate>Sat, 10 Sep 2022 18:41:22 +0900</pubDate><guid>http://kenji.blog/ko/p/papermod%E3%81%A7twitter-card%E3%82%92%E8%A8%AD%E5%AE%9A%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/</guid><description>&lt;img src="http://kenji.blog/p/papermod%E3%81%A7twitter-card%E3%82%92%E8%A8%AD%E5%AE%9A%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/images/img.png" alt="Featured image of post 'PaperMod에서 Twitter Card를 설정하는 방법'" />&lt;h1 id="시작하며">시작하며
&lt;/h1>&lt;p>PaperMod 테마는 Twitter Card를 지원합니다.
단, Twitter Card 설정은 &lt;code>config.toml&lt;/code> 또는 각 게시물의 &lt;code>*.md&lt;/code> 헤더 정보에 작성해야 합니다.
각 게시물과 &lt;code>config.toml&lt;/code> 양쪽에 설정한 경우에는, 각 게시물의 헤더 정보가 우선됩니다.&lt;/p>
&lt;h1 id="설정-방법">설정 방법
&lt;/h1>&lt;h2 id="configtoml">config.toml
&lt;/h2>&lt;p>&lt;code>config.toml&lt;/code>에는 &lt;code>[params]&lt;/code> 아래에 &lt;code>images&lt;/code>라는 항목을 추가합니다.
&lt;code>images&lt;/code>에는 Twitter Card에 표시할 이미지의 경로를 작성합니다.
이미지를 &lt;code>static&lt;/code> 폴더에 배치할 경우에는 파일 이름만 지정하면 됩니다.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">[params]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> images = [&amp;#34;twitter_card.jpg&amp;#34;]
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>폴더 구성&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">root
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ config.toml (여기에 작성)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├─content
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ └─posts
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ └─게시물 폴더
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ │ index.md (여기에 작성)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ └─images
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ cover.png (여기에 배치)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">└─static
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> twitter_card.jpg (여기에 배치)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="각-게시물의-헤더-정보">각 게시물의 헤더 정보
&lt;/h2>&lt;p>각 게시물의 헤더 정보에는 &lt;code>cover&lt;/code> 아래에 &lt;code>image&lt;/code>라는 항목을 추가합니다.
&lt;code>relative&lt;/code>를 &lt;code>true&lt;/code>로 하면, 게시물의 &lt;code>*.md&lt;/code>로부터의 상대 경로로 지정할 수 있습니다.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">cover:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> image: &amp;#34;images/cover.jpg&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> relative: true
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="게시물-상단에는-표시하고-싶지-않은-경우">게시물 상단에는 표시하고 싶지 않은 경우
&lt;/h3>&lt;p>게시물 상단에 커버 이미지를 표시하고 싶지 않은 경우에는 &lt;code>cover&lt;/code> 아래에 &lt;code>hidden&lt;/code>이라는 항목을 추가하고 &lt;code>true&lt;/code>로 설정합니다.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">cover:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> image: &amp;#34;images/cover.jpg&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> relative: true
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> hidden: true
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h1 id="이미지-크기에-대하여">이미지 크기에 대하여
&lt;/h1>&lt;p>현재 PaperMod의 사양상 Twitter Card의 크기는 &lt;code>summary_large_image&lt;/code>만 지원하는 것 같습니다.
&lt;code>summary_large_image&lt;/code>의 적절한 크기(해상도)는 여러 의견이 있지만 &lt;code>800 x 418&lt;/code>(이미지 비율 1.91:1) 정도가 좋을 것 같습니다.&lt;/p>
&lt;p>&lt;a class="link" href="https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/summary-card-with-large-image" target="_blank" rel="noopener"
>참고 사이트1&lt;/a>
&lt;a class="link" href="https://developers.facebook.com/docs/sharing/best-practices" target="_blank" rel="noopener"
>참고 사이트2&lt;/a>&lt;/p>
&lt;p>가능하다면, 이미지 크기를 리사이징하여 게시하는 것을 추천합니다.&lt;/p>
&lt;h1 id="설정-확인-방법">설정 확인 방법
&lt;/h1>&lt;p>Twitter Card의 설정을 확인하려면 &lt;a class="link" href="https://cards-dev.twittercom/validator" target="_blank" rel="noopener"
>Twitter Card Validator&lt;/a>를 이용합니다.
단, 제 환경에서는 미리보기가 잘 표시되지 않았기 때문에, 만약 미리보기가 표시되지 않는다면 비공개 계정 등을 이용해 게시 전에 한번 확인해 보는 것을 추천합니다.&lt;/p></description></item></channel></rss>