5 changed files with 87 additions and 49 deletions
@ -1 +0,0 @@ |
|||||||
exports.graphql_endpoint = 'https://www.facebook.com/api/graphql/'; |
|
||||||
@ -0,0 +1,43 @@ |
|||||||
|
const { get_event } = require('./logic'); |
||||||
|
|
||||||
|
const { do_request } = require('./facebook-request'); |
||||||
|
|
||||||
|
const do_event_request = async (doc_id, event_id) => { |
||||||
|
let variables = { |
||||||
|
eventID: `${event_id}`, |
||||||
|
}; |
||||||
|
const res = await do_request(doc_id, variables); |
||||||
|
return get_event(res); |
||||||
|
}; |
||||||
|
|
||||||
|
/// EventsAboutTheVenueCardRendererQuery
|
||||||
|
const do_event_location_request = (event_id) => { |
||||||
|
const doc_id = '1634531006589990'; |
||||||
|
return do_event_request(doc_id, event_id); |
||||||
|
}; |
||||||
|
|
||||||
|
/// EventsRelayTicketButtonCallableQuery
|
||||||
|
const do_event_ticket_request = (event_id) => { |
||||||
|
const doc_id = '3806351372819867'; |
||||||
|
return do_event_request(doc_id, event_id); |
||||||
|
}; |
||||||
|
|
||||||
|
/// EventsEventDetailsCardRendererQuery
|
||||||
|
const do_event_desc_request = (event_id) => { |
||||||
|
const doc_id = '4360465050633785'; |
||||||
|
return do_event_request(doc_id, event_id); |
||||||
|
}; |
||||||
|
|
||||||
|
const get_event_details = async (event_id) => { |
||||||
|
const res = await Promise.all([ |
||||||
|
do_event_ticket_request(event_id), |
||||||
|
do_event_location_request(event_id), |
||||||
|
do_event_desc_request(event_id), |
||||||
|
]); |
||||||
|
const event = res.reduce((acc, event) => ({ ...acc, ...event }), {}); |
||||||
|
return event; |
||||||
|
}; |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
get_event_details, |
||||||
|
}; |
||||||
@ -1,59 +1,14 @@ |
|||||||
const { graphql_endpoint } = require('./constants'); |
|
||||||
const { |
const { |
||||||
get_edges, |
get_edges, |
||||||
get_event, |
|
||||||
get_page_info, |
get_page_info, |
||||||
get_past_events_from_page, |
get_past_events_from_page, |
||||||
get_upcoming_events_from_page, |
get_upcoming_events_from_page, |
||||||
map_event, |
map_event, |
||||||
sleep, |
sleep, |
||||||
} = require('./logic'); |
} = require('./logic'); |
||||||
const fetch = require('node-fetch'); |
|
||||||
const last = require('ramda/src/last'); |
|
||||||
|
|
||||||
const do_request = async (doc_id, variables) => { |
|
||||||
const params = new URLSearchParams(); |
|
||||||
params.append('doc_id', doc_id); |
|
||||||
params.append('variables', JSON.stringify(variables)); |
|
||||||
|
|
||||||
const fetch_options = { |
|
||||||
headers: { |
|
||||||
'Content-Type': 'application/x-www-form-urlencoded', |
|
||||||
}, |
|
||||||
body: params, |
|
||||||
method: 'POST', |
|
||||||
}; |
|
||||||
|
|
||||||
let res = null; |
const { do_request } = require('./facebook-request'); |
||||||
try { |
const last = require('ramda/src/last'); |
||||||
res = await fetch(graphql_endpoint, fetch_options); |
|
||||||
} catch (e) { |
|
||||||
console.error(e); |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
if (!res.ok) { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
try { |
|
||||||
res = await res.json(); |
|
||||||
} catch (e) { |
|
||||||
console.error(e); |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
return res; |
|
||||||
}; |
|
||||||
|
|
||||||
const do_event_location_request = async (event_id) => { |
|
||||||
const doc_id = '1634531006589990'; |
|
||||||
let variables = { |
|
||||||
eventID: `${event_id}`, |
|
||||||
}; |
|
||||||
const res = await do_request(doc_id, variables); |
|
||||||
return get_event(res); |
|
||||||
}; |
|
||||||
|
|
||||||
const do_events_request = async (page_id, doc_id, cursor = null) => { |
const do_events_request = async (page_id, doc_id, cursor = null) => { |
||||||
let variables = { |
let variables = { |
||||||
@ -0,0 +1,41 @@ |
|||||||
|
const fetch = require('node-fetch'); |
||||||
|
const graphql_endpoint = 'https://www.facebook.com/api/graphql/'; |
||||||
|
|
||||||
|
const do_request = async (doc_id, variables) => { |
||||||
|
const params = new URLSearchParams(); |
||||||
|
params.append('doc_id', doc_id); |
||||||
|
params.append('variables', JSON.stringify(variables)); |
||||||
|
|
||||||
|
const fetch_options = { |
||||||
|
headers: { |
||||||
|
'Content-Type': 'application/x-www-form-urlencoded', |
||||||
|
}, |
||||||
|
body: params, |
||||||
|
method: 'POST', |
||||||
|
}; |
||||||
|
|
||||||
|
let res = null; |
||||||
|
try { |
||||||
|
res = await fetch(graphql_endpoint, fetch_options); |
||||||
|
} catch (e) { |
||||||
|
console.error(e); |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
if (!res.ok) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
try { |
||||||
|
res = await res.json(); |
||||||
|
} catch (e) { |
||||||
|
console.error(e); |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
return res; |
||||||
|
}; |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
do_request, |
||||||
|
}; |
||||||
Loading…
Reference in new issue