<?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/fr/tags/twitter/</link><description>Recent content in Twitter on kenji.blog</description><generator>Hugo -- gohugo.io</generator><language>fr</language><copyright>kenjinote</copyright><lastBuildDate>Sat, 08 Apr 2023 18:48:32 +0900</lastBuildDate><atom:link href="http://kenji.blog/fr/tags/twitter/index.xml" rel="self" type="application/rss+xml"/><item><title>Comment tweeter en utilisant l'API Twitter et Google Colaboratory</title><link>http://kenji.blog/fr/p/comment-tweeter-en-utilisant-l-api-twitter-et-google-colaboratory/</link><pubDate>Sat, 08 Apr 2023 18:48:32 +0900</pubDate><guid>http://kenji.blog/fr/p/comment-tweeter-en-utilisant-l-api-twitter-et-google-colaboratory/</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 Comment tweeter en utilisant l'API Twitter et Google Colaboratory" />&lt;h1 id="ce-dont-vous-avez-besoin">Ce dont vous avez besoin
&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>Compte Google&lt;/li>
&lt;/ul>
&lt;p>Consultez le site de référence pour savoir comment obtenir l&amp;rsquo;API Twitter.&lt;/p>
&lt;h1 id="étapes-pour-tweeter-à-laide-de-lapi">Étapes pour tweeter à l&amp;rsquo;aide de l&amp;rsquo;API
&lt;/h1>&lt;ol>
&lt;li>Accédez à &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>Sélectionnez &amp;ldquo;Fichier&amp;rdquo; -&amp;gt; &amp;ldquo;Nouveau notebook&amp;rdquo;&lt;/li>
&lt;li>Collez et exécutez le code ci-dessous (veuillez utiliser vos propres valeurs réelles obtenues)&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>Collez et exécutez le code ci-dessous&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>Collez et exécutez le code ci-dessous (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>→ Un tweet disant &lt;code>hello&lt;/code> sera publié.&lt;/p>
&lt;ol start="5">
&lt;li>Collez et exécutez le code ci-dessous (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>→ Un tweet disant &lt;code>hello v2&lt;/code> sera publié.&lt;/p>
&lt;p>C&amp;rsquo;est tout.&lt;/p>
&lt;h1 id="référence">Référence
&lt;/h1>&lt;ul>
&lt;li>&lt;a class="link" href="https://bloomtectec.com/twitter-api-application-procedure/" target="_blank" rel="noopener"
>【À partir d&amp;rsquo;avril 2021】Explication détaillée de la demande d&amp;rsquo;utilisation de l&amp;rsquo;API Twitter avec des exemples de phrases d&amp;rsquo;utilisation et des captures d&amp;rsquo;écran&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="https://bloomtectec.com/use-twitter-api-in-google-colab/" target="_blank" rel="noopener"
>【Pas besoin de paramètres compliqués !】Google Colaboratory est recommandé comme environnement de test pour l&amp;rsquo;API Twitter 【Le code source est également partagé】&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="https://3pysci.com/tweepy-28/" target="_blank" rel="noopener"
>【Tweepy】Twitter API v2 : Tweets, réponses, tweets avec sondages, tweets avec médias (v1.1) [Python]&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Comment configurer Twitter Card avec PaperMod</title><link>http://kenji.blog/fr/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/fr/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 Comment configurer Twitter Card avec PaperMod" />&lt;h1 id="introduction">Introduction
&lt;/h1>&lt;p>Le thème PaperMod prend en charge Twitter Card.
Cependant, les paramètres de Twitter Card doivent être écrits dans le &lt;code>config.toml&lt;/code> ou dans les informations d&amp;rsquo;en-tête du &lt;code>*.md&lt;/code> de chaque article.
Si vous le configurez à la fois dans chaque article et dans le &lt;code>config.toml&lt;/code>, les informations d&amp;rsquo;en-tête de chaque article seront prioritaires.&lt;/p>
&lt;h1 id="comment-configurer">Comment configurer
&lt;/h1>&lt;h2 id="configtoml">config.toml
&lt;/h2>&lt;p>Dans &lt;code>config.toml&lt;/code>, ajoutez un élément appelé &lt;code>images&lt;/code> sous &lt;code>[params]&lt;/code>.
Dans &lt;code>images&lt;/code>, décrivez le chemin de l&amp;rsquo;image à afficher sur Twitter Card.
Si vous placez l&amp;rsquo;image dans le dossier &lt;code>static&lt;/code>, il suffit de spécifier uniquement le nom du fichier.&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>Structure des dossiers&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 (Écrire ici)
&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">│ └─Dossier de l&amp;#39;article
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ │ index.md (Écrire ici)
&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 (Placer ici)
&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 (Placer ici)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="informations-den-tête-de-chaque-article">Informations d&amp;rsquo;en-tête de chaque article
&lt;/h2>&lt;p>Dans les informations d&amp;rsquo;en-tête de chaque article, ajoutez un élément appelé &lt;code>image&lt;/code> sous &lt;code>cover&lt;/code>.
Si vous définissez &lt;code>relative&lt;/code> sur &lt;code>true&lt;/code>, vous pouvez spécifier avec un chemin relatif à partir du &lt;code>*.md&lt;/code> de l&amp;rsquo;article.&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="si-vous-ne-souhaitez-pas-lafficher-en-haut-de-larticle">Si vous ne souhaitez pas l&amp;rsquo;afficher en haut de l&amp;rsquo;article
&lt;/h3>&lt;p>Si vous ne souhaitez pas afficher l&amp;rsquo;image de couverture en haut de l&amp;rsquo;article, ajoutez un élément appelé &lt;code>hidden&lt;/code> sous &lt;code>cover&lt;/code> et définissez-le sur &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="à-propos-de-la-taille-de-limage">À propos de la taille de l&amp;rsquo;image
&lt;/h1>&lt;p>Dans les spécifications actuelles de PaperMod, il semble que la taille de Twitter Card ne prenne en charge que &lt;code>summary_large_image&lt;/code>.
La taille appropriée (résolution) de &lt;code>summary_large_image&lt;/code> a plusieurs théories, mais autour de &lt;code>800 x 418&lt;/code> (ratio d&amp;rsquo;image 1.91:1) semble être bon.&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"
>Site de référence 1&lt;/a>
&lt;a class="link" href="https://developers.facebook.com/docs/sharing/best-practices" target="_blank" rel="noopener"
>Site de référence 2&lt;/a>&lt;/p>
&lt;p>Si possible, nous vous recommandons de redimensionner la taille de l&amp;rsquo;image avant de publier.&lt;/p>
&lt;h1 id="comment-vérifier-les-paramètres">Comment vérifier les paramètres
&lt;/h1>&lt;p>Pour vérifier les paramètres de Twitter Card, utilisez le &lt;a class="link" href="https://cards-dev.twitter.com/validator" target="_blank" rel="noopener"
>Twitter Card Validator&lt;/a>.
Cependant, comme l&amp;rsquo;aperçu ne s&amp;rsquo;est pas affiché correctement dans mon environnement, si l&amp;rsquo;aperçu n&amp;rsquo;apparaît pas, je vous recommande de vérifier une fois avant de publier en utilisant un compte privé ou similaire.&lt;/p></description></item></channel></rss>