Fix facebook the way it should be fixed

This commit is contained in:
redfast00 2019-12-08 14:49:55 +01:00
parent 320f2d86ca
commit c2f3855e31
No known key found for this signature in database
GPG key ID: 5946E0E34FD0553C

View file

@ -1,30 +0,0 @@
# frozen_string_literal: true
require 'net/http'
require 'json'
usage 'fetch [facebook event id]'
aliases :f
summary 'Fetch an event from facebook'
description 'Fetch an event from facebook'
run do |_opts, args, _cmd|
fb_token = File.read('.fb_token')
event_id = args[0]
uri = URI("https://graph.facebook.com/v2.10/#{event_id}?fields=cover,name,description,start_time,place,end_time&access_token=#{fb_token}")
o = JSON.parse(Net::HTTP.get(uri))
puts <<~EOS
---
title: "#{o['name']}"
description: #Fill in
time: #{o['start_time']}
end: #{o['end_time']}
location: #{o['place']['name']}
banner: #{o['cover']['source']}
created_at: #Fill in
facebook: 'https://www.facebook.com/events/#{event_id}/'
---
#{o['description']}
EOS
end