0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

特定のキーワードでFacebookの投稿を検索して結果を返してくれるpowershellのプログラムは作れますか?

Posted at

image.png
1.Facebook Developersサイトでアプリケーションを作成します。
2.Facebook Graph APIを呼び出すためのアクセストークンを取得します。
3.PowerShellスクリプトで、Invoke-RestMethodを使用して、Graph APIエンドポイントにHTTPリクエストを送信します。
4.クエリパラメータを使用して、キーワード検索の条件を指定します。
5.結果をパースして、必要な情報を取得します。

以下は、PowerShellスクリプトの例です。この例では、Facebook Graph APIを使用して、キーワード「PowerShell」で投稿を検索して、投稿のメッセージをコンソールに表示します。

$accessToken = 'your_access_token_here'
$searchKeyword = 'PowerShell'

$url = "https://graph.facebook.com/v14.0/search?q=$searchKeyword&type=post&access_token=$accessToken"

$searchResult = Invoke-RestMethod -Method Get -Uri $url

foreach($post in $searchResult.data) {
    Write-Host $post.message
}

上記の例では、$accessToken変数にアクセストークンを、$searchKeyword変数に検索キーワードを指定しています。次に、Invoke-RestMethodコマンドレットを使用して、Graph APIエンドポイントにHTTP GETリクエストを送信し、$searchResult変数に検索結果を格納しています。最後に、$searchResult.dataプロパティにアクセスして、投稿のメッセージをコンソールに表示しています。

なお、FacebookのAPI利用には、一定の制限がある場合がありますので、注意が必要です。また、APIの利用には事前に適切な権限を持ったFacebookアカウントでログインする必要があります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?