<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>webhooks | Men of Letters（メン・オブ・レターズ） &#8211; 論理的思考/業務改善/プログラミング</title>
	<atom:link href="https://laboratory.kazuuu.net/category/webhooks/feed/" rel="self" type="application/rss+xml" />
	<link>https://laboratory.kazuuu.net</link>
	<description></description>
	<lastBuildDate>Fri, 04 Nov 2022 20:39:28 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.1</generator>

<image>
	<url>https://laboratory.kazuuu.net/wp-content/uploads/2021/02/cropped-L-32x32.png</url>
	<title>webhooks | Men of Letters（メン・オブ・レターズ） &#8211; 論理的思考/業務改善/プログラミング</title>
	<link>https://laboratory.kazuuu.net</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/>
<atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/>
<atom:link rel="hub" href="https://websubhub.com/hub"/>
<atom:link rel="self" href="https://laboratory.kazuuu.net/category/webhooks/feed/"/>
	<item>
		<title>WebhookやHTTPリクエストのテストやデバッグが行える「Webhook.site」</title>
		<link>https://laboratory.kazuuu.net/webhook-site-for-testing-and-debugging-webhook-and-http-requests/</link>
					<comments>https://laboratory.kazuuu.net/webhook-site-for-testing-and-debugging-webhook-and-http-requests/#respond</comments>
		
		<dc:creator><![CDATA[小林]]></dc:creator>
		<pubDate>Fri, 04 Nov 2022 20:39:28 +0000</pubDate>
				<category><![CDATA[webhooks]]></category>
		<guid isPermaLink="false">https://laboratory.kazuuu.net/?p=12563</guid>

					<description><![CDATA[WebhookやHTTPリクエストのテストやデバッグが行える「Webhook.site」について解説しています。 Webhook.site（https://webhook.site/）は、ユニークでランダムなURLとEメ [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>WebhookやHTTPリクエストのテストやデバッグが行える「Webhook.site」について解説しています。</p>
<p>Webhook.site（<a href="https://webhook.site/">https://webhook.site/</a>）は、ユニークでランダムなURLとEメールアドレスを即座に取得することができます。取得したアドレスに送信されたものは、すべて即座に表示されるようになっていますので、WebhookやHTTPリクエストのテストやデバッグ、検証などが行なえます。</p>
<p>Webhook.siteのドキュメント（<a href="https://docs.webhook.site/">https://docs.webhook.site/</a>）。</p>
<h2>■料金プラン</h2>
<p>Webhook.siteは無料で使用することができるが、Pro（プロ）、Enterprise（企業）向けの2つのサブスクリプションが存在する。加入することで、発行されるURLでより多くのことができ、データのプライバシーと安全性を保つことができる。料金についてはこちら（<a href="https://docs.webhook.site/pro.html">https://docs.webhook.site/pro.html</a>）。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://laboratory.kazuuu.net/webhook-site-for-testing-and-debugging-webhook-and-http-requests/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Pythonでrequestを使用しWebhookを送信する</title>
		<link>https://laboratory.kazuuu.net/sending-a-webhook-using-request-in-python/</link>
					<comments>https://laboratory.kazuuu.net/sending-a-webhook-using-request-in-python/#respond</comments>
		
		<dc:creator><![CDATA[小林]]></dc:creator>
		<pubDate>Tue, 01 Nov 2022 20:37:40 +0000</pubDate>
				<category><![CDATA[Python【初歩から現場実務的なもの】]]></category>
		<category><![CDATA[webhooks]]></category>
		<guid isPermaLink="false">https://laboratory.kazuuu.net/?p=12568</guid>

					<description><![CDATA[Pythonでrequestを使用しWebhookを送信してみます。 今回はrequestモジュールを用います。このモジュール・ライブラリを、インストールしていない場合は、インストールする必要があります。 目次 ■Pyt [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Pythonでrequestを使用しWebhookを送信してみます。</p>
<p>今回はrequestモジュールを用います。このモジュール・ライブラリを、インストールしていない場合は、インストールする必要があります。</p>

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-4" checked><label class="toc-title" for="toc-checkbox-4">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">■Python</a></li><li><a href="#toc2" tabindex="0">■Webhook.siteを使用し一意のURLを取得する</a></li><li><a href="#toc3" tabindex="0">■requestモジュールを使用しWebhookを送信する</a><ol><li><a href="#toc4" tabindex="0">■コード</a></li></ol></li><li><a href="#toc5" tabindex="0">■実行・検証</a></li></ol>
    </div>
  </div>

<h2><span id="toc1">■Python</span></h2>
<p><a href="https://laboratory.kazuuu.net/wp-content/uploads/2021/05/スクリーンショット-2021-05-15-072949.png"><img fetchpriority="high" decoding="async" class="alignnone size-medium wp-image-8343" src="https://laboratory.kazuuu.net/wp-content/uploads/2021/05/スクリーンショット-2021-05-15-072949-300x197.png" alt="" width="300" height="197" srcset="https://laboratory.kazuuu.net/wp-content/uploads/2021/05/スクリーンショット-2021-05-15-072949-300x197.png 300w, https://laboratory.kazuuu.net/wp-content/uploads/2021/05/スクリーンショット-2021-05-15-072949-1024x671.png 1024w, https://laboratory.kazuuu.net/wp-content/uploads/2021/05/スクリーンショット-2021-05-15-072949-768x503.png 768w, https://laboratory.kazuuu.net/wp-content/uploads/2021/05/スクリーンショット-2021-05-15-072949.png 1250w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>今回のPythonのバージョンは、「3.8.5」を使用しています。（Windows10）（pythonランチャーでの確認）</p>
<h2><span id="toc2">■Webhook.siteを使用し一意のURLを取得する</span></h2>
<p>requestを使用しWebhookを送信してみますが、その前にWebhook.siteを使用し一意のURLを取得します。</p>
<p>まずはWebブラウザを起動し、Webhook.site（<a href="https://webhook.site/">https://webhook.site/</a>）にアクセスします。</p>
<p><a href="https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-120624-1.png"><img decoding="async" class="alignnone size-medium wp-image-12569" src="https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-120624-1-300x114.png" alt="" width="300" height="114" srcset="https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-120624-1-300x114.png 300w, https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-120624-1-1024x390.png 1024w, https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-120624-1-768x292.png 768w, https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-120624-1.png 1250w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>アクセスすると、ウェブページに「Your unique URL (Please copy it from here, not from the address bar!)」と表示されており、その下の欄に表示されているURLをコピーします。</p>
<p>これで一意のURLの取得は完了となります。取得は完了しましたが、検証でWebhook.site（<a href="https://webhook.site/">https://webhook.site/</a>）にアクセスしますので、Webブラウザは開いたままにします。</p>
<h2><span id="toc3">■requestモジュールを使用しWebhookを送信する</span></h2>
<p>完了後、requestモジュールを使用しWebhookを送信するスクリプトを書いていきます。</p>
<h3><span id="toc4">■コード</span></h3>
<pre>import requests
import json

webhook_url = 'https://webhook.site/******-****-*****'

data = {'名前':'テスト太郎',
        '性別':'男性',
        'URL':'https://laboratory.kazuuu.net/'}

r = requests.post(webhook_url,data=json.dumps(data),headers={'Content-Type':'application/json'})</pre>
<p>importでrequestsとjsonモジュールを呼び出します。Pythonの標準ライブラリであるjsonモジュールは、Webhookを送信する際に、データをjson形式にして送信するときに用いる。</p>
<p>呼び出した後にwebhook_urlという変数を定義し、その中に先程取得したURLを格納します。</p>
<p>格納後、dataという変数を定義し、その中にJSON形式でデータを格納します。</p>
<p>その後にrという変数を定義し、その中でrequests.post()を用います。第1の引数,パラメータとして、webhook_urlを渡します。第2の引数,パラメータとしてdataを渡しますが、その際にjson.dump()を用います。この関数を用いることでJSON形式の文字列に変換できます。第3の引数,パラメータ（headers=）としてJSONリクエストなので、「&#8217;Content-Type&#8217;:&#8217;application/json&#8217;」を指定します。</p>
<p>これで、スクリプトを実行すると、POSTリクエストが送信されます。</p>
<h2><span id="toc5">■実行・検証</span></h2>
<p>このスクリプトを「web_h.py」という名前で、Pythonが実行されている作業ディレクトリ（カレントディレクトリ）に保存し、コマンドプロンプトを起動します。</p>
<p><a href="https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-123135-1.png"><img decoding="async" class="alignnone size-medium wp-image-12571" src="https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-123135-1-300x156.png" alt="" width="300" height="156" srcset="https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-123135-1-300x156.png 300w, https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-123135-1-1024x531.png 1024w, https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-123135-1-768x398.png 768w, https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-123135-1.png 1249w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>起動後、スクリプトを実行してみると、何も出力されませんでした。</p>
<p><a href="https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-123445.png"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-12572" src="https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-123445-300x148.png" alt="" width="300" height="148" srcset="https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-123445-300x148.png 300w, https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-123445-1024x506.png 1024w, https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-123445-768x380.png 768w, https://laboratory.kazuuu.net/wp-content/uploads/2022/06/スクリーンショット-2022-06-13-123445.png 1207w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>何も出力されていませんが、Webhook.site（<a href="https://webhook.site/">https://webhook.site/</a>）にアクセスすると、「Request Details（リクエストの詳細）」として、Webhookを送信したときの情報が表示されていることが確認できました。また「Raw Content」には、JSON形式のデータも送信され届いていることが確認できました。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://laboratory.kazuuu.net/sending-a-webhook-using-request-in-python/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
