{"id":11984,"date":"2021-08-12T04:55:00","date_gmt":"2021-08-11T20:55:00","guid":{"rendered":"http:\/\/222.73.203.234:9999\/?p=11984"},"modified":"2022-03-28T15:17:48","modified_gmt":"2022-03-28T07:17:48","slug":"%e9%80%9a%e8%bf%87twython%e5%9c%a8raspberry-pi%e4%b8%8a%e5%8f%91%e6%8e%a8%e6%96%87%ef%bc%81%ef%bc%88%e7%ac%ac1%e9%83%a8%e5%88%86%ef%bc%89-2","status":"publish","type":"post","link":"https:\/\/techclass.rohm.com.cn\/knowledge\/tech-info\/raspberry\/11984","title":{"rendered":"\u901a\u8fc7Twython\u5728Raspberry Pi\u4e0a\u53d1\u63a8\u6587\uff01\uff08\u7b2c1\u90e8\u5206\uff09"},"content":{"rendered":"<div class=\"\u201cthe_content_wrapper\u201d\">\u8fd9\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e<a href=\"https:\/\/www.deviceplus.com\/\">DevicePlus.com<\/a>\u82f1\u8bed\u7f51\u7ad9\u7684\u7ffb\u8bd1\u7a3f\u3002<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" class=\"wp-image-8144\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-1-Getting-Started.png\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-1-Getting-Started.png 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-1-Getting-Started-300x198.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-1-Getting-Started-222x146.png 222w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-1-Getting-Started-50x33.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-1-Getting-Started-114x75.png 114w\" alt=\"Tweet on Raspberry Pi via Twython\"><\/figure>\n<\/div>\n<p><em>\u539f\u6587\u6700\u521d\u7531<\/em><a href=\"https:\/\/deviceplus.jp\/\"><em>deviceplus.jp<\/em><\/a><em>\u53d1\u5e03\uff0c\u672c\u6587\u4e3a\u82f1\u8bd1\u7248\u3002<\/em><br \/>\n\u4eca\u5929\uff0c\u6211\u5c06\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u201cTwython\u201d\u5b9e\u73b0Raspberry Pi\u4e0eTwitter\uff08\u63a8\u7279\uff09\u4e4b\u95f4\u7684\u8fde\u63a5\u3002\u6211\u8fc7\u53bb\u66fe\u7ecf\u5c1d\u8bd5\u8fc7\u8fde\u63a5Twitter\uff0c\u4f46\u662f\u6bd4\u60f3\u50cf\u7684\u8981\u96be\uff01\u8fd9\u6b21\uff0c\u6211\u4eec\u5c06\u6309\u7167<a href=\"https:\/\/projects.raspberrypi.org\/en\/projects\/getting-started-with-the-twitter-api\">Raspberry Pi \u5b98\u65b9\u7f51\u7ad9\u6587\u6863<\/a>\u91cc\u7684\u65b9\u6cd5\u6765\u8fdb\u884c\u3002\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u75282017\u5e7411\u670829\u65e5\u53d1\u5e03\u7684\u201cRaspbian Stretch with desktop\u201d\u64cd\u4f5c\u7cfb\u7edf\u548c\u201c<a href=\"https:\/\/www.deviceplus.com\/raspberry-pi\/raspberrypi_entry_015\/\">Raspberry Pi2<\/a>Model B\u201d\u3002<\/p>\n<h2><strong>\u4ec0\u4e48\u662fTwython?<\/strong><\/h2>\n<p><a href=\"https:\/\/twython.readthedocs.io\/en\/latest\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Twython \u5b98\u65b9\u7f51\u7ad9<\/a><br \/>\n<em><a href=\"https:\/\/twython.readthedocs.io\/en\/latest\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Twython \u2013 Twython 3.6.0 \u6587\u6863<\/a><\/em><br \/>\n<em>\u7528\u4e8eTwitterAPI\u7684\u79ef\u6781\u7ef4\u62a4\u7684\u7eafPython\u88c5\u9970\u5668\u3002\u652f\u6301\u5e38\u89c4\u548c\u6d41\u5f0fTwitter APIs\u3002<\/em><br \/>\n\u300cTwython\u300d\u662f\u4e00\u4e2a\u7528\u4e8eTwitter API\u7684Python\u5e93\u3002<br \/>\n<em><a href=\"https:\/\/developer.twitter.com\/en\/docs\/developer-utilities\/twitter-libraries\" target=\"_blank\" rel=\"noreferrer noopener\" label=\" (opens in a new tab)\" class=\"broken_link\">Twitter \u5e93 \u2014 Twitter \u5f00\u53d1\u8005<\/a><\/em><br \/>\n<em>twython by @ryanmcgrath\u2014\u7528\u4e8eTwitter API\u7684\u79ef\u6781\u7ef4\u62a4\u7684\u7eafPython\u88c5\u9970\u5668\u3002\u652f\u6301\u5e38\u89c4\u548c\u6d41\u5f0fTwitter APIs\u3002\u652f\u6301\u6240\u6709v1.1\u7aef\u70b9\uff0c\u5305\u62ec\u52a8\u6001\u51fd\u6570\uff0c\u56e0\u6b64\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u5e93\u4e2d\u5c1a\u672a\u5305\u542b\u7684\u7aef\u70b9\u3002<\/em><br \/>\n\u5b98\u65b9Twitter\u4e2d\u4e5f\u4ecb\u7ecd\u4e86\u8fd9\u4e00\u70b9\u3002<\/p>\n<h2><strong>\u5b89\u88c5 Twython<\/strong><\/h2>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-8145\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-2-Installing-Twython.png\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-2-Installing-Twython.png 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-2-Installing-Twython-300x198.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-2-Installing-Twython-222x146.png 222w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-2-Installing-Twython-50x33.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-2-Installing-Twython-114x75.png 114w\" alt=\"Steps to install Twython \"><figcaption>\u56fe 1<\/figcaption><\/figure>\n<p><a href=\"https:\/\/projects.raspberrypi.org\/en\/projects\/getting-started-with-the-twitter-api\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Getting Started with the Twitter API (opens in a new tab)\">Twitter API \u5165\u95e8\u7b80\u4ecb<\/a><br \/>\n\u73b0\u5728\u6211\u4eec\u7ee7\u7eed\u3002\u5f53\u60a8\u60f3\u5207\u6362\u9875\u9762\u65f6\uff0c\u8bf7\u70b9\u51fb\u5de6\u4fa7\u83dc\u5355\uff0c\u56e0\u4e3aURL\u4e0d\u53ef\u4ee5\u66f4\u6539\u3002<br \/>\n\u6b63\u6570\u7b2c\u4e8c\u4e2a\u9009\u9879\uff0c\u201c\u60a8\u9700\u8981\u4ec0\u4e48\u201d\uff0c\u91cc\u9762\u63cf\u8ff0\u4e86\u5982\u4f55\u5b89\u88c5\u201c\u7528\u4e8ePython 3\u7684Twython\u201d\u3002<br \/>\n\u50cf\u5f80\u5e38\u4e00\u6837\uff0c\u6211\u4eec\u5148\u5bf9\u7cfb\u7edf\u8fdb\u884c\u66f4\u65b0\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>&lt;em&gt;sudo apt-get update&lt;\/em&gt;\r\n<\/code><\/pre>\n<\/div>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>&lt;em&gt;sudo apt-get upgrade&lt;\/em&gt;\r\n<\/code><\/pre>\n<\/div>\n<p>\u63a5\u4e0b\u6765\uff0c\u8f93\u5165\u201cTwython\u201d\u5b89\u88c5\u6307\u4ee4\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>&lt;em&gt;sudo pip3 install twython&lt;\/em&gt;\r\n<\/code><\/pre>\n<\/div>\n<p>\u4e4b\u540e\u5c06\u663e\u793a\u5982\u4e0b\u4fe1\u606f\uff1a<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-8146\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-3-Installing-Twython-icon.png\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-3-Installing-Twython-icon.png 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-3-Installing-Twython-icon-300x14.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-3-Installing-Twython-icon-260x12.png 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-3-Installing-Twython-icon-50x2.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-3-Installing-Twython-icon-150x7.png 150w\" alt=\"Install Twython icon with Raspberry Pi \"><figcaption>\u56fe 2<\/figcaption><\/figure>\n<p>\u8f93\u5165\u201cpip3 list\u201d\u6307\u4ee4\uff0c\u663e\u793a\u5185\u5bb9\u4e2d\u6709\u201ctwython (3.4.0)\u201d\uff0c\u8bc1\u660e\u5b89\u88c5\u6210\u529f\u3002<br \/>\n\u6700\u540e\uff0c\u6267\u884c\u4e00\u4e2a\u786e\u8ba4\u6307\u4ee4\uff0c\u68c0\u67e5\u6240\u9700\u8981\u7684\u5185\u5bb9\u662f\u5426\u5df2\u5177\u5907\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>&lt;em&gt;python3 -c \"import twython\"&lt;\/em&gt;&lt;br&gt;\r\n<\/code><\/pre>\n<\/div>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-8147\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-4-Import-Twython.png\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-4-Import-Twython.png 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-4-Import-Twython-300x23.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-4-Import-Twython-260x20.png 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-4-Import-Twython-50x4.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-4-Import-Twython-150x11.png 150w\" alt=\"Install Twython icon with Raspberry Pi \"><figcaption>\u56fe 3<\/figcaption><\/figure>\n<p>\u5982\u679c\u6ca1\u6709\u51fa\u73b0\u9519\u8bef\u4fe1\u606f\uff0c\u5c31\u8868\u793a\u51c6\u5907\u5de5\u4f5c\u5df2\u7ecf\u5b8c\u6210\uff01<br \/>\n\u5728\u9875\u9762\u672b\u5c3e\uff0c\u6709\u4e00\u6761\u8b66\u544a\u4fe1\u606f\u6307\u51fa\u4f7f\u7528Twitter API\u9700\u8981\u5df2\u9a8c\u8bc1\u7684\u7535\u8bdd\u53f7\u7801\u3002\u5982\u679c\u60a8\u6ca1\u6709\u6ce8\u518c\u7535\u8bdd\u53f7\u7801\uff0c\u5c06\u65e0\u6cd5\u5728\u5e94\u7528\u7a0b\u5e8f\u4e0a\u5b8c\u6210Twitter\u7684\u6ce8\u518c\uff0c\u56e0\u6b64\u8bf7\u52a1\u5fc5\u5148\u5b8c\u6210\u7535\u8bdd\u53f7\u7801\u7684\u6ce8\u518c\u3002<\/p>\n<h2><strong>\u6ce8\u518c\u4e00\u4e2aTwitter\u8d26\u6237<\/strong><\/h2>\n<p>\u7b2c\u4e09\u6761\u4e2d\u7684\u201c\u521b\u5efa\u4e00\u4e2aTwitter\u8d26\u6237\u201d\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u521b\u5efaTwitter\u8d26\u6237\u3002\u5bf9\u4e8e\u7b2c\u4e00\u6b21\u6ce8\u518c\u7684\u7528\u6237\uff0c\u8bf7\u53c2\u8003<a href=\"https:\/\/twitter.com\/\" target=\"_blank\" rel=\"noreferrer noopener\" label=\" (opens in a new tab)\" class=\"broken_link\">Twitter \u5b98\u65b9\u7f51\u7ad9<\/a>\u4e0a\u7684\u4fe1\u606f\u5bf9\u8d26\u6237\u8fdb\u884c\u8bbe\u7f6e\u3002\u5982\u679c\u4f7f\u7528\u7684\u662f\u5df2\u6709\u8d26\u6237\uff0c\u8bf7\u8f6c\u81f3\u7b2c\u56db\u9875\u3002<br \/>\n\u201c\u521b\u5efa\u4e00\u4e2aTwitter\u5e94\u7528\u7a0b\u5e8f\u201d\u4e2d\u8be6\u7ec6\u8bf4\u660e\u4e86\u5982\u4f55\u521b\u5efa\u4e00\u4e2aTwitter\u5e94\u7528\u7a0b\u5e8f\u3002<br \/>\n\u5728<a href=\"https:\/\/apps.twitter.com\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"broken_link\">Twitter \u5e94\u7528\u7a0b\u5e8f\u7ba1\u7406<\/a>\u9875\u9762\u4e2d\u767b\u5f55Twitter\u8d26\u6237\uff0c\u5e76\u70b9\u51fb\u201c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5e94\u7528\u7a0b\u5e8f\u201d\u6309\u94ae\u3002<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-8149\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-5-Application-details.png\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-5-Application-details.png 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-5-Application-details-300x227.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-5-Application-details-193x146.png 193w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-5-Application-details-50x38.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-5-Application-details-99x75.png 99w\" alt=\"How to add Twitter application details\"><figcaption>\u56fe 4<\/figcaption><\/figure>\n<p>\u63a5\u4e0b\u6765\uff0c\u8f93\u5165\u201c\u540d\u79f0\u201d\u3001\u201c\u63cf\u8ff0\u201d\u548c\u201c\u7f51\u5740\u201d\u3002\u5728\u201c\u7f51\u5740\u201d\u8f93\u5165\u76f8\u5e94\u5185\u5bb9\u662f\u5fc5\u8981\u7684\uff0c\u4f46\u662f\u56e0\u4e3a\u6211\u4e0d\u4f1a\u516c\u5f00\u6b64\u8d26\u53f7\uff0c\u6240\u4ee5\u5728\u8fd9\u91cc\u6211\u8f93\u5165\u4e86\u81ea\u5df1\u7684Twitter URL\u3002\u540c\u610f\u6761\u6b3e\u548c\u6761\u7ea6\u540e\uff0c\u70b9\u51fb\u201c\u521b\u5efa\u60a8\u7684Twitter\u5e94\u7528\u7a0b\u5e8f\u201d\u6309\u94ae\u3002<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-8150\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-6-Application-details-error.png\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-6-Application-details-error.png 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-6-Application-details-error-300x29.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-6-Application-details-error-260x25.png 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-6-Application-details-error-50x5.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-6-Application-details-error-150x15.png 150w\" alt=\" Twitter application details error\"><figcaption>\u56fe 5<\/figcaption><\/figure>\n<p>\u5982\u679c\u60a8\u6ca1\u6709\u4e3a\u60a8\u7684Twitter\u8d26\u6237\u6ce8\u518c\u7535\u8bdd\u53f7\u7801\uff0c\u5c06\u4f1a\u51fa\u73b0\u4ee5\u4e0a\u9519\u8bef\u4fe1\u606f\u3002<br \/>\n\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u65f6\uff0c\u8bf7\u53c2\u9605\u4ee5\u4e0b\u6587\u4ef6\u6765\u6ce8\u518c\u7535\u8bdd\u53f7\u7801\u3002<br \/>\n<a href=\"https:\/\/help.twitter.com\/en\/managing-your-account\/how-to-add-a-phone-number-to-your-account\" target=\"_blank\" rel=\"noreferrer noopener\" label=\" (opens in a new tab)\" class=\"broken_link\">\u5982\u4f55\u4e3a\u60a8\u7684\u8d26\u6237\u6ce8\u518c\u7535\u8bdd\u53f7\u7801<\/a><\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-8151\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-7-Key-and-access-token.png\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-7-Key-and-access-token.png 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-7-Key-and-access-token-300x270.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-7-Key-and-access-token-162x146.png 162w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-7-Key-and-access-token-50x45.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-7-Key-and-access-token-83x75.png 83w\" alt=\"How to create my access token \"><figcaption>\u56fe 6<\/figcaption><\/figure>\n<p>\u5b8c\u6210\u6ce8\u518c\u540e\uff0c\u70b9\u51fb\u201c\u5bc6\u94a5\u548c\u8bbf\u95ee\u4ee4\u724c\u201d\u6309\u94ae\u3002<br \/>\n\u201c\u6d88\u8d39\u8005\u5bc6\u94a5\uff08API\u5bc6\u94a5\uff09\u201d\u548c\u201c\u6d88\u8d39\u8005\u79d8\u5bc6\uff08API\u79d8\u5bc6\uff09\u201d\u662f\u4f7f\u7528Twython\u8fdb\u884c\u76f8\u5173\u9a8c\u8bc1\u65f6\u9700\u8981\u7684\u503c\u3002<br \/>\n\u9996\u5148\uff0c\u6211\u4eec\u6765\u786e\u8ba4\u4e00\u4e0b\u8bbf\u95ee\u7ea7\u522b\u3002<br \/>\n\u5982\u679c\u60a8\u5c06\u5176\u8bbe\u7f6e\u4e3a\u201c\u53ef\u8bfb\u548c\u53ef\u5199\u201d\uff0c\u90a3\u5c31\u6ca1\u95ee\u9898\u4e86\u3002\u6211\u5c06\u8be5\u8bbe\u5b9a\u4f5c\u4e3a\u9ed8\u8ba4\u8bbe\u7f6e\uff0c\u4f46\u662f\u60a8\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u201c\u4fee\u6539\u5e94\u7528\u7a0b\u5e8f\u6743\u9650\u201d\u94fe\u63a5\u968f\u65f6\u5bf9\u5176\u8fdb\u884c\u66f4\u6539\u3002<br \/>\n\u63a5\u4e0b\u6765\u662f\u521b\u5efa\u8bbf\u95ee\u4ee4\u724c\u3002\u70b9\u51fb\u5c4f\u5e55\u5e95\u90e8\u7684\u201c\u521b\u5efa\u6211\u7684\u8bbf\u95ee\u4ee4\u724c\u201d\u6309\u94ae\u3002<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-8152\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-8-Access-token.png\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-8-Access-token.png 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-8-Access-token-300x105.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-8-Access-token-260x91.png 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-8-Access-token-50x17.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-8-Access-token-150x52.png 150w\" alt=\"Where to find my access token \"><figcaption>\u56fe 7<\/figcaption><\/figure>\n<p>\u5728\u201c\u60a8\u7684\u8bbf\u95ee\u4ee4\u724c\u201d\u4e0b\uff0c\u5c06\u663e\u793a\u201c\u8bbf\u95ee\u4ee4\u724c\u201d\u548c\u201c\u8bbf\u95ee\u4ee4\u724c\u79d8\u5bc6\u201d\u3002\u4e0e\u4e4b\u524d\u7684\u201c\u6d88\u8d39\u8005\u5bc6\u94a5\uff08API\u5bc6\u94a5\uff09\u201d\u548c\u201c\u6d88\u8d39\u8005\u79d8\u5bc6\uff08API\u79d8\u5bc6\uff09\u201d\u76f8\u540c\uff0c\u4f7f\u7528Twython\u65f6\u4f1a\u7528\u5230\u8fd9\u4e9b\u503c\u3002<\/p>\n<h2><strong>\u8bbe\u7f6e\u65e5\u671f\/\u65f6\u95f4<\/strong><\/h2>\n<p>\u7b2c\u4e94\u9875\u4e2d\u7684\u201c\u8bbe\u7f6e\u7cfb\u7edf\u65e5\u671f\/\u65f6\u95f4\u201d\u662f\u8bbe\u7f6e\u65e5\u671f\u548c\u65f6\u95f4\u7684\u6709\u5173\u4fe1\u606f\uff0c\u6240\u4ee5\u6211\u4eec\u5728Raspberry Pi\u7684\u8bbe\u7f6e\u4e2d\u5bf9\u65e5\u671f\u548c\u65f6\u95f4\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n<h2><strong>\u5728Twitter\u4e0a\u53d1\u5e16\uff01<\/strong><\/h2>\n<p>\u8fdb\u884c\u5230\u7b2c\u516d\u9875\u4e2d\u201c\u4ecePython\u53d1\u9001\u4e00\u6761\u63a8\u6587\u201d\u8fd9\u4e00\u6b65\uff0c\u6211\u4eec\u7ec8\u4e8e\u6709\u4e86\u5199\u7a0b\u5e8f\u7684\u673a\u4f1a\uff01\u4ece\u83dc\u5355\u4e2d\u9009\u62e9\u201cProgramming\uff08\u7f16\u7a0b\uff09\u201d\u2014\u201cPython 3(IDEL)\u201d\u5e76\u6253\u5f00\u7f16\u8f91\u5668\u3002<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-8153\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-9-Posting-on-twitter.png\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-9-Posting-on-twitter.png 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-9-Posting-on-twitter-300x120.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-9-Posting-on-twitter-260x104.png 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-9-Posting-on-twitter-50x20.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-9-Posting-on-twitter-150x60.png 150w\" alt=\"Posting on twitter with Twyton\"><figcaption>\u56fe 8<\/figcaption><\/figure>\n<p>\u6700\u521d\u663e\u793a\u7684\u5185\u5bb9\u5982\u4e0a\u6240\u793a\uff0c\u4f46\u662f\u5982\u679c\u4e00\u76f4\u8fd9\u6837\u4fdd\u6301\u4e0d\u53d8\uff0c\u90a3\u4e48\u5c06\u4f1a\u4f9d\u6b21\u9010\u884c\u6267\u884c\u6240\u6709\u7684\u6307\u4ee4\uff0c\u6240\u4ee5\u6211\u4eec\u6765\u70b9\u51fb[File] \u2013 [New File]\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7a0b\u5e8f\u3002\u6309\u7167\u4e0b\u56fe\u987a\u5e8f\u4f9d\u6b21\u5199\u5165\u201cConsumer Key (API Key)\u201d\u3001\u201cConsumer Secret (API Secret)\u201d\u3001\u201cAccess Token\u201d\u3001\u201cAccess Token Secret\u201d\uff0c\u5e76\u5c06\u5176\u50a8\u5b58\u5728\u540d\u4e3a\u201cauth.py\u201d\u7684\u6587\u4ef6\u4e2d\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>01\r\n02 consumer_key &amp;nbsp;= 'ABCDEFGHIJKLKMNOPQRSTUVWXYZ'\r\n03\r\n04 consumer_secret = '1234567890ABCDEFGHIJKLMNOPQRSTUVXYZ'\r\n   access_token = 'ZYXWVUTSRQPONMLKJIHFEDCBA'\r\n   access_token_secret = '0987654321ZYXWVUTSRQPONMLKJIHFEDCBA'\r\n<\/code><\/pre>\n<\/div>\n<p>\u5199Python\u7a0b\u5e8f\u7684\u65f6\u5019\u9700\u8981\u6ce8\u610f\uff0c\u524d\u5bfc\u7a7a\u683c\u548c\u5236\u8868\u7b26\u6240\u5bfc\u81f4\u7684\u7f29\u8fdb\u4f1a\u5bf9\u7a0b\u5e8f\u4ea7\u751f\u5f71\u54cd\u3002<br \/>\n\uff08\u7f29\u8fdb\u5b57\u7b26\u76f8\u540c\u7684\u884c\u4f1a\u88ab\u89c6\u4e3a\u5757\uff09<br \/>\n\u6211\u5c06\u8be5\u6587\u4ef6\u4fdd\u5b58\u5728\u201c\/home\/pi\/\u201d\u76ee\u5f55\u4e2d\u3002\u6211\u60f3\u5f53\u60a8\u4ee5pi\u7528\u6237\u7684\u8eab\u4efd\u767b\u5f55\u65f6\uff0c\u8be5\u76ee\u5f55\u4f1a\u88ab\u8ba4\u4e3a\u662f\u9ed8\u8ba4\u4fdd\u5b58\u8def\u5f84\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u4f1a\u8f93\u5165\u7528\u4e8eTwitter\u53d1\u5e16\u7684\u7a0b\u5e8f\u3002\u518d\u4e00\u6b21\u70b9\u51fb[File]-[New File]\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\uff0c\u5e76\u5199\u5165\u7a0b\u5e8f\uff0c\u5982\u4e0b\u6240\u793a\u3002\u7136\u540e\uff0c\u5c06\u6587\u4ef6\u547d\u540d\u4e3a\u201ctwitter.py\u201d\u5e76\u4fdd\u5b58\u5230\u4e0e\u201cauth.py\u201d\u76f8\u540c\u7684\u8def\u5f84\u4e2d\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>01\r\n02  from twython import Twython\r\n03\r\n04  from auth import (\r\n05\r\n06     consumer_key,\r\n07\r\n08     consumer_secret,\r\n09\r\n10     access_token,\r\n11\r\n12     access_token_secret\r\n13  )\r\n14\r\n15\r\n16  twitter = Twython(\r\n17\r\n18     consumer_key,\r\n       consumer_secret,\r\n       access_token,\r\n       access_token_secret\r\n)\r\nmessage = \"Hello world!\"\r\ntwitter.update_status(status=message)\r\nprint(\"Tweeted: %s\" % message)\r\n<\/code><\/pre>\n<\/div>\n<p>\u5728\u201ctwitter.py\u201d\u7a97\u53e3\u5904\u4e8e\u6d3b\u52a8\u72b6\u6001\u65f6\uff0c\u6309\u4e0b\u201cF5\u201d\u952e\u6216\u6267\u884c\u9876\u90e8\u83dc\u5355\u4e2d\u7684\u201cRun -&gt; Run Module\u201d\u3002<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-8160\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-10-Hello-world-tweeted.png\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-10-Hello-world-tweeted.png 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-10-Hello-world-tweeted-300x121.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-10-Hello-world-tweeted-260x105.png 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-10-Hello-world-tweeted-50x20.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-10-Hello-world-tweeted-150x61.png 150w\" alt=\"Your first tweet on Raspberry pi \"><figcaption>\u56fe 9<\/figcaption><\/figure>\n<p>\u7136\u540e\u6267\u884c\u5c4f\u5e55\u5e94\u663e\u793a \u300cTweeted:Hello world!\u300d<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-8162\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-11-Tweet-Hello-world-1.png\" sizes=\"(max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-11-Tweet-Hello-world-1.png 700w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-11-Tweet-Hello-world-1-300x138.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-11-Tweet-Hello-world-1-260x119.png 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-11-Tweet-Hello-world-1-50x23.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-11-Tweet-Hello-world-1-150x69.png 150w\" alt=\"Hello world tweet  \"><figcaption>\u56fe 10<\/figcaption><\/figure>\n<p>\u6211\u4eec\u901a\u8fc7\u8bbf\u95eeTwitter\u6765\u5bf9\u8be5\u7ed3\u679c\u8fdb\u884c\u786e\u8ba4\u3002\u5982\u679c\u201cHello world!\u201d\u88ab\u53d1\u5e03\uff0c\u5c31\u8bc1\u660e\u6211\u4eec\u6210\u529f\u4e86\uff01<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-8163\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-12-Tweet-Successful.png\" sizes=\"(max-width: 640px) 100vw, 640px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-12-Tweet-Successful.png 640w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-12-Tweet-Successful-300x240.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-12-Tweet-Successful-182x146.png 182w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-12-Tweet-Successful-50x40.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2019\/02\/Raspberry-pi-twython-12-Tweet-Successful-94x75.png 94w\" alt=\"Successfully tweeted with Twython in Raspberry Pi \"><figcaption>\u56fe 11<\/figcaption><\/figure>\n<p>\u5982\u679c\u60a8\u7ee7\u7eed\u53d1\u5e03\u76f8\u540c\u7684\u63a8\u6587\uff0c\u5219\u4f1a\u51fa\u73b0\u5982\u4e0a\u6240\u793a\u7684\u9519\u8bef\u6d88\u606f\u3002\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u65f6\uff0c\u8bf7\u5c1d\u8bd5\u66f4\u6539\u201c\u63a8\u6587\u201d\u7684\u5185\u5bb9\u6216\u8005\u8bcd\u5e8f\u4ee5\u4f7f\u5176\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<h2><strong>\u603b\u7ed3<\/strong><\/h2>\n<p>\u5728\u201cTwython\u201d\u7684\u7b2c1\u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u4ec5\u4ecb\u7ecd\u5230\u63a8\u6587\u7684\u5b57\u7b26\u8bcd\u5e8f\u8fd9\u4e00\u90e8\u5206\u3002<br \/>\n\u4e4b\u524d\u5f53\u6211\u505aTwitter\u7684\u6709\u5173\u9879\u76ee\u65f6\uff0c\u6211\u4f1a\u76f4\u63a5\u8bbf\u95eeTwitter\u7684API\uff0c\u4f46\u662f\u7528\u4e86\u8fd9\u4e2a\u5e93\u4e4b\u540e\u96be\u5ea6\u4f1a\u964d\u4f4e\u5f88\u591a\u3002<br \/>\n\u6211\u8ba4\u4e3a\uff0c\u4ee5Python\u4e3a\u57fa\u7840\u7684\u201cTwython\u201d\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5e94\u7528\u5230\u4efb\u4f55\u4f7f\u7528\u5143\u5668\u4ef6\u7684\u7535\u5b50\u4ea7\u54c1\u4e2d\u5b9e\u73b0\u4e00\u4e9b\u529f\u80fd\uff0c\u5982\u53d1\u5e03\u7167\u7247\u3001\u641c\u7d22\u63a8\u6587\u7b49\u7b49\u3002\u6211\u4eec\u5c06\u5728\u4e0b\u4e00\u7bc7\u6587\u7ae0\u4e2d\u8fdb\u4e00\u6b65\u8ba8\u8bba\u8fd9\u4e9b\u5185\u5bb9\uff01<br \/>\n\u4e0b\u4e00\u6b21\uff0c\u6211\u4eec\u5c06\u6267\u884c<a href=\"https:\/\/projects.raspberrypi.org\/en\/projects\/getting-started-with-the-twitter-api\/7\">\u6587\u6863<\/a>7-9\u9875\u7684\u5185\u5bb9\uff0c\u5e76\u5c1d\u8bd5\u53d1\u5e03\u591a\u79cd\u7c7b\u578b\u7684\u63a8\u6587\uff01<\/p>\n<div class=\"author-box-wrapper\">\n<div class=\"avatar-wrapper\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/micro.rohm.com.cn\/deviceplus\/wp-content\/uploads\/2018\/08\/Device-Plus-logo-for-author-info-75x75.png\" alt=\"DevicePlus \u7f16\u8f91\u56e2\u961f\" width=\"64\" height=\"64\"><\/div>\n<div class=\"desc-wrapper\">\n<h5>DevicePlus \u7f16\u8f91\u56e2\u961f<\/h5>\n<div class=\"desc\">\n\u8bbe\u5907\u5347\u7ea7\u7248\u9002\u7528\u4e8e\u6240\u6709\u70ed\u7231\u7535\u5b50\u548c\u673a\u7535\u4e00\u4f53\u5316\u7684\u4eba\u3002<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"\u8fd9\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8eDevicePlus.com\u82f1\u8bed\u7f51\u7ad9\u7684\u7ffb\u8bd1\u7a3f\u3002 \u539f\u6587\u6700\u521d\u7531deviceplus.jp\u53d1\u5e03\uff0c\u672c\u6587\u4e3a [&hellip;]","protected":false},"author":7,"featured_media":16050,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1132],"tags":[],"acf":[],"wps_subtitle":"","_links":{"self":[{"href":"https:\/\/techclass.rohm.com.cn\/wp-json\/wp\/v2\/posts\/11984"}],"collection":[{"href":"https:\/\/techclass.rohm.com.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techclass.rohm.com.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techclass.rohm.com.cn\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/techclass.rohm.com.cn\/wp-json\/wp\/v2\/comments?post=11984"}],"version-history":[{"count":2,"href":"https:\/\/techclass.rohm.com.cn\/wp-json\/wp\/v2\/posts\/11984\/revisions"}],"predecessor-version":[{"id":16855,"href":"https:\/\/techclass.rohm.com.cn\/wp-json\/wp\/v2\/posts\/11984\/revisions\/16855"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techclass.rohm.com.cn\/wp-json\/wp\/v2\/media\/16050"}],"wp:attachment":[{"href":"https:\/\/techclass.rohm.com.cn\/wp-json\/wp\/v2\/media?parent=11984"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techclass.rohm.com.cn\/wp-json\/wp\/v2\/categories?post=11984"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techclass.rohm.com.cn\/wp-json\/wp\/v2\/tags?post=11984"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}