Was this helpful?
Facebook Pages is a feature on Facebook that allows businesses, organizations, and other entities to create a presence on the social media platform. These pages can include information such as opening hours, address, contact information, and more.
Alpaca is a travel content platform that allows developers to build websites and applications with travel-related content, such as curated lists, top-10 lists, trips, and trails. The Alpaca Travel GraphQL API allows developers to access a wide range of travel-related information and use it to build these itineraries.
By integrating Facebook Pages with the Alpaca Travel GraphQL API, developers can access additional information about places and businesses, such as opening hours, address, and other details, that are associated with the Facebook page. This information can be used to enhance the user experience and provide more detailed and accurate itineraries for users. Developers can also use the API to search for places and businesses, and plot them onto the itineraries they are building, which can help users better plan and navigate their trips.
When working with Facebook Pages on the Alpaca platform, it's important to understand how IDs are used and how to reference the Facebook Page.
On Facebook, each page is assigned a unique numeric ID. This ID can be used to access information about the page, such as opening hours, address, and contact information, through the Facebook Pages API. In addition to the numeric ID, Facebook also allows pages to be accessed using the last part of the page's URL, such as "mavisthegrocer" in the URL "https://www.facebook.com/mavisthegrocer".
place/facebook:page:<facebook_page_id>
On the Alpaca platform, we use a unique ID to reference each provider, including Facebook Pages. The ID for a Facebook Page on Alpaca will take the form "place/facebook:page:12345" where "12345" is the ID of the Facebook Page. This ID format allows us to reference multiple providers within the platform, and make sure that we can distinguish between them.
It is also possible to use the last part of the page's URL (if available) to reference the Facebook Page on Alpaca. But it's important to note that this might not be the case always and you should always use the numeric ID (if you have it) as the primary reference.
To reference a Facebook Page on the Alpaca platform, developers can use the unique ID assigned to the page by Facebook. The ID can be found by visiting the page on Facebook and looking at the URL. It is the last string after the last slash. For example, in the URL "https://www.facebook.com/mavisthegrocer" the ID is "mavisthegrocer".
Alternatively, you can use the last part of the page's URL (if available) as an alternative way to reference the Facebook Page on Alpaca.
Once the ID is obtained, developers can use it to make requests to the Alpaca Travel GraphQL API and retrieve information about the page. This information can then be used to enhance the user experience and provide more detailed and accurate itineraries for users.
1query GetPlace {
2 place(id: "place/facebook:page:370266689818691") {
3 name
4 synopsis
5
6 position {
7 lon
8 lat
9 }
10
11 # Images
12 images: mediaContainers(first: 3) {
13 nodes {
14 resource {
15 ... on MediaImage {
16 url(bestFit: [200, 200])
17 copyright
18 attribution
19 caption
20 }
21 }
22 }
23 }
24
25 # Source and Attribution
26 contributor
27
28 address {
29 addressLineOne
30 locality
31 region
32 country
33 }
34
35 contact {
36 facebookUrl
37 }
38
39 # Some specific facebook information
40 likes: attrValue(id: "place/facebook:likes")
41 ratings: attrValue(id: "place/facebook:ratings-count")
42 starRating: attrValue(id: "place/facebook:star-rating")
43 checkins: attrValue(id: "place/facebook:checkins")
44 }
45}
Sandbox: Configure | Try Operation
If successul, a response may look like the following:
1{
2 "data": {
3 "place": {
4 "name": "Mavis The Grocer",
5 "synopsis": "We choose our suppliers & growers very carefully to offer only the finest of seasonal, local, sustainable, ethically sourced & organic produce.",
6 "position": {
7 "lon": 144.99702,
8 "lat": -37.8031099
9 },
10 "images": {
11 "nodes": ...
12 },
13 "contributor": "Facebook",
14 "address": {
15 "addressLineOne": "197 Vere Street",
16 "locality": "Abbotsford",
17 "region": "VIC",
18 "country": "Australia"
19 },
20 "contact": {
21 "facebookUrl": "https://www.facebook.com/370266689818691"
22 },
23 "likes": 2301,
24 "ratings": 39,
25 "starRating": 4.2,
26 "checkins": 829
27 }
28 }
29}
You can also find all the attributes that are available for a location with the following query:
1query {
2 place(id: "place/facebook:page:370266689818691") {
3 id
4
5 # Load the first 30 attributes for the product
6 attrs(first: 30) {
7 edges {
8 node {
9 id
10 value
11 }
12 }
13 }
14 }
15}
Sandbox: Configure | Try Operation
Where opening hours are available, you can use the Alpaca platform to interpret and display opening hours of locations.
Search for a upcoming or future range
Localise the hours to a different timezone
Identify public holidays that could affect opening hours
Change the format and display for dates and times
Alpaca also offers the inclusion of Public Holidays in order to flag to users of your website or application that they may have affected operating hours due to local observed public holidays.
1# Obtain the open/closed hours for the place given a period, such as the
2# upcoming week or future date range. Includes information on local public
3# holidays that could affect opening hours.
4
5query QueryDateRangeOpenClosedTimes($placeId: ID!) {
6 # Use the place() operation
7 place(id: $placeId) {
8 # Access the opening hours (where specified)
9 hours {
10 # Use the forDays operation to obtain days across a range of dates. By
11 # default, without any arguments the next 7 days will be selected. You
12 # can change the range by specifying an alternative offset (which allows
13 # you to specify values like { days: 14 }) or provide a specific start and
14 # end dates (as ISO-8601 date strings)
15 forDays {
16 # Date/day, as ISO-8601, or as formatted for presentation using the
17 # Unicode Technical Standard #35 Date Field Symbols
18 date(format: "EEE, MMM d")
19 # Whether there is a public holiday for this date detected for this
20 # region on this date
21 publicHolidays
22 # Obtain the intervals for this date, requesting the opening status
23 # status is optional, otherwise use Open/Closed to specify your pref
24 intervals(status: Open) {
25 # Hours, from/to as ISO-8601 string, or formatted using the Unicode
26 # Technical Standard #35 Date Field Symbols
27 from(format: "h:mm a")
28 to(format: "h:mm a")
29 # Status (Open/Closed)
30 status
31 # Any corresponding comment for the opening hours
32 comment
33 }
34 }
35 }
36 }
37}
Sandbox: Configure | Try Operation
1{
2 "data": {
3 "place": {
4 "hours": {
5 "forDays": [
6 {
7 "date": "Mon, Jan 23",
8 "publicHolidays": [],
9 "intervals": [
10 {
11 "from": "7:00 AM",
12 "to": "3:30 PM",
13 "status": "Open",
14 "comment": null
15 }
16 ]
17 },
18 {
19 "date": "Tue, Jan 24",
20 "publicHolidays": [],
21 "intervals": [
22 {
23 "from": "7:00 AM",
24 "to": "3:30 PM",
25 "status": "Open",
26 "comment": null
27 }
28 ]
29 },
30 {
31 "date": "Wed, Jan 25",
32 "publicHolidays": [],
33 "intervals": [
34 {
35 "from": "7:00 AM",
36 "to": "3:30 PM",
37 "status": "Open",
38 "comment": null
39 }
40 ]
41 },
42 {
43 "date": "Thu, Jan 26",
44 "publicHolidays": ["Australia Day"],
45 "intervals": [
46 {
47 "from": "7:00 AM",
48 "to": "3:30 PM",
49 "status": "Open",
50 "comment": null
51 }
52 ]
53 },
54 {
55 "date": "Fri, Jan 27",
56 "publicHolidays": [],
57 "intervals": [
58 {
59 "from": "7:00 AM",
60 "to": "3:30 PM",
61 "status": "Open",
62 "comment": null
63 }
64 ]
65 },
66 {
67 "date": "Sat, Jan 28",
68 "publicHolidays": [],
69 "intervals": [
70 {
71 "from": "8:00 AM",
72 "to": "3:30 PM",
73 "status": "Open",
74 "comment": null
75 }
76 ]
77 },
78 {
79 "date": "Sun, Jan 29",
80 "publicHolidays": [],
81 "intervals": [
82 {
83 "from": "9:00 AM",
84 "to": "3:30 PM",
85 "status": "Open",
86 "comment": null
87 }
88 ]
89 }
90 ]
91 }
92 }
93 }
94}
You can also leverage the place search capabilities of the API by specifying the
sources
as Facebook
.
1query SearchPlaceAutocompleteFromFacebook {
2 # use the placeAutocompleteSearch operation to query Facebook Pages
3 placeAutocompleteSearch(
4 first: 3
5 text: "Mavis the Grocer"
6 sources: Facebook
7 ) {
8 edges {
9 # Can build single or multiple line responses
10 single {
11 label
12 matches {
13 length
14 offset
15 }
16 }
17
18 # The place information
19 node {
20 # Basic identifiers
21 id
22 name
23
24 # Location to show on a map
25 position {
26 lon
27 lat
28 }
29
30 # Context from adddress
31 address {
32 region
33 country
34 }
35 }
36 }
37 }
38}
Sandbox: Configure | Try Operation
If successful, a response may look like the following:
1{
2 "data": {
3 "placeAutocompleteSearch": {
4 "edges": [
5 {
6 "single": {
7 "label": "Mavis The Grocer, 197 Vere Street, Melbourne",
8 "matches": [
9 {
10 "length": 5,
11 "offset": 0
12 },
13 {
14 "length": 3,
15 "offset": 6
16 },
17 {
18 "length": 6,
19 "offset": 10
20 }
21 ]
22 },
23 "node": {
24 "id": "place/facebook:page:370266689818691",
25 "name": "Mavis The Grocer",
26 "position": {
27 "lon": 144.99702,
28 "lat": -37.8031099
29 },
30 "address": {
31 "region": "VIC",
32 "country": "Australia"
33 }
34 }
35 },
36 {
37 "single": {
38 "label": "The Grocer, Shop 2, 12-20 Ocean St, Sunshine Coast",
39 "matches": [
40 {
41 "length": 3,
42 "offset": 0
43 },
44 {
45 "length": 6,
46 "offset": 4
47 }
48 ]
49 },
50 "node": {
51 "id": "place/facebook:page:107192972168755",
52 "name": "The Grocer",
53 "position": {
54 "lon": 153.09140014648,
55 "lat": -26.652830262873
56 },
57 "address": {
58 "region": "QLD",
59 "country": "Australia"
60 }
61 }
62 },
63 {
64 "single": {
65 "label": "The Grocer, Bridgewater, SA",
66 "matches": [
67 {
68 "length": 3,
69 "offset": 0
70 },
71 {
72 "length": 6,
73 "offset": 4
74 }
75 ]
76 },
77 "node": {
78 "id": "place/facebook:page:336261170085742",
79 "name": "The Grocer",
80 "position": {
81 "lon": 138.75989069709,
82 "lat": -35.009106062166
83 },
84 "address": {
85 "region": "SA",
86 "country": "Australia"
87 }
88 }
89 }
90 ]
91 }
92 }
93}
To use the Facebook API directly, a developer will first need to create a Facebook App. This can be done by visiting the Facebook Developers website (https://developers.facebook.com/) and following these steps:
Log in to your Facebook account and click on the "My Apps" drop-down menu in the top right corner.
Select "Create App" from the menu.
Select the platform that you will be using the API with, such as "Website" or "iOS", and click on "Create App ID".
Fill out the form with your app's information and click on "Create App ID".
Once the app is created, the developer will be able to access their Application ID, which is a unique identifier for their app. The Application ID will be used in API calls to identify the app making the request.
To obtain the necessary permissions to access the Facebook API, the developer will need to submit a request to Facebook, specifying which permissions they need. The developer can then use this access token to make API calls and access the information they need.
It's important to note that in order to use the Facebook API, developers must comply with Facebook's policies and guidelines, which can be found here: https://developers.facebook.com/docs/marketing-apis/policies/
Additionally, the developer should also check out the Facebook API documentation, which provides detailed information about the different types of API calls that can be made and the data that can be retrieved. The link for the documentation is https://developers.facebook.com/docs/pages/access-tokens
Furthermore, for more information on how to get started with the Facebook API, developers can also check out the Facebook Developer's guide, which can be found here: https://developers.facebook.com/docs/pages/getting-started
Copyright © 2024 - Made with love ❤️ in Australia.