Versi Graph API

Product Catalog Hotels

Hotels in a catalog used in Dynamic Ads for Travel. See Dynamic Ads for Travel, Catalog Setup.

When you use this, you can provide Batch Requests to combine a number of API calls into one HTTP request.

For example, to get the total number of hotels in a catalog:

curl -G \
-d "summary=total_count" \
-d "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<API_VERSION>/<PRODUCT_CATALOG_ID>/hotels

To fetch hotels whose name contains "suites":

curl -G \
-d 'fields=["hotel_id","name"]' \
-d 'filter={"name":{"i_contains":"suites"}}' \
-d 'access_token=<ACCESS_TOKEN>'
https://graph.facebook.com/<API_VERSION>/<PRODUCT_CATALOG_ID>/hotels

Membaca

Endpoint that returns the hotels from a catalog

Contoh

Graph API Explorer
GET /v19.0/{product-catalog-id}/hotels HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{product-catalog-id}/hotels',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "/{product-catalog-id}/hotels",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{product-catalog-id}/hotels",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{product-catalog-id}/hotels"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];
Jika Anda ingin mempelajari cara menggunakan Graph API, baca Menggunakan panduan Graph API kami.

Parameter

ParameterKeterangan
bulk_pagination
boolean

Used for iterating over the edge in large chunks

filter
A JSON-encoded rule

JSON-encoded WCA rule expression representing the filter to be applied for the edge

Kolom

Jika membaca dari edge ini, maka akan mengembalikan hasil berformat JSON:

{ "data": [], "paging": {}, "summary": {} }

data

Daftar dari node Hotel.

paging

Untuk perincian selengkapnya tentang penomoran halaman, lihat panduan Graph API.

summary

Informasi agregat tentang edge tersebut, seperti jumlah. Tentukan kolom untuk diambil di parameter ringkasan (seperti ringkasan=total_count).

KolomKeterangan
total_count
unsigned int32

Total number of hotels returned by the query

Error Codes

KesalahanDescription
368The action attempted has been deemed abusive or is otherwise disallowed
100Invalid parameter
2500Error parsing graph query

Membuat

Example

Example to create a hotel:

curl \
-X POST \
-F "hotel_id=h_157" \
-F "name=Sample Hotel" \
-F "images= [ \
  {'image_url':'http://www.example.com/pic1.jpg', 'tags':['front view']}, \
  {'image_url':'http://www.example.com/pic2.jpg', 'tags':['lobby view']} \
]" \
-F "url=http://www.example.com/samplehotel" \
-F "address={ \
  street_address:'1 Hacker Way', \
  city:'Menlo Park', \
  region:'California', \
  country:'United States', \
  postal_code:'94025', \
  neighborhoods:['Palo Alto','Menlo Park'], \
  latitude:37.484116, \
  longitude:-122.148244 \
}" \
-F "brand=hotel brand" \
-F "description=hotel description" \
-F "guest_ratings= [ \
  {'score':7.8, 'rating_system':'sample_rating', 'number_of_raters':780} \
]" \
-F "star_rating=4" \
-F "loyalty_program=Sample rewards club" \
-F "phone=+351234123456" \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<API_VERSION>/<PRODUCT_CATALOG_ID>/hotels

You can make a POST request to hotels edge from the following paths:
When posting to this edge, a Hotel will be created.

Parameter

ParameterKeterangan
address
Object

The address of the hotel

Diperlukan
city
string

Diperlukan
city_id
string

country
string

Diperlukan
latitude
float

Diperlukan
longitude
float

Diperlukan
neighborhoods
list<string>

postal_code
string

region
string

Diperlukan
street_address
string

Diperlukan
applinks
Object

App links for native platforms, e.g. Android, IOS and Windows Phone.

web

android

ios

ipad

iphone

windows_phone

base_price
int64

The base price of the hotel

brand
string

Hotel brand

currency
ISO 4217 Currency Code
Nilai default: USD

The currency for base_price, e.g. USD

description
string

Description of the hotel

Diperlukan
guest_ratings
list<Object>

Guest ratings for this hotel.

score
float

Diperlukan
max_score
int64

Diperlukan
rating_system
string

Diperlukan
number_of_raters
int64

Diperlukan
hotel_id
string

A unique identifier for this hotel provided by advertiser. (i.e. from the id field in the feed

images
list<Object>

Links to hotel images. Please note that carousel format utilizes a square 1:1 aspect ratio images (recommended size - 600x600px) while single hotel ad uses 1.91:1 aspect ratio image(recommended size - 1200x630px). Please provide at least one image.

Diperlukan
image_url
URL

Diperlukan
tags
list<string>

name
string

Name of the hotel

Diperlukan
phone
phone number string

Hotel's phone number

star_rating
float

The star rating of the hotel

url
URL

Link to the external site where you can book a hotel room

Diperlukan

Jenis Pengembalian

This endpoint supports read-after-write and will read the node represented by id in the return type.
Struct {
id: numeric string,
}

Error Codes

KesalahanDescription
100Invalid parameter

Memperbarui

Anda tidak dapat melakukan operasi ini pada titik akhir ini.

Menghapus

Anda tidak dapat melakukan operasi ini pada titik akhir ini.