Я пытаюсь получить обзор отелей от expedia.com, используя API-вызов graphql, у меня есть запрос graphql и его переменная
, когда я пытаюсь с почтальоном вернуть правильный результат, но когда я пытаюсь с cURL php ничего не возвращается
вот мой URL
https://www.expedia.com/graphql
вот мои данные строки для почтового запроса
{
"operationName": "Reviews",
"query": "query Reviews($context: ContextInput!, $propertyId: String!, $pagination: PaginationInput!, $sortBy: PropertyReviewSort!, $filters: PropertyReviewFiltersInput!) {propertyInfo(propertyId: $propertyId, context: $context) {reviewInfo(sortBy: $sortBy, pagination: $pagination, filters: $filters) { summary { superlative totalCount { raw formatted } reviewCountLocalized averageOverallRating { raw formatted } cleanliness { raw formatted } serviceAndStaff { raw formatted } amenityScore { raw formatted } hotelCondition { raw formatted } cleanlinessPercent cleanlinessOverMax serviceAndStaffPercent serviceAndStaffOverMax amenityScorePercent amenityScoreOverMax hotelConditionPercent hotelConditionOverMax ratingCounts { count { formatted raw } percent rating } lastIndex reviewDisclaimer } reviews { id ratingOverall superlative submissionTime { raw } title text locale author userLocation stayDuration helpfulReviewVotes negativeRemarks positiveRemarks locationRemarks photos { description url } managementResponses { id date displayLocale userNickname response } travelers themes { icon { id description } label } } sortAndFilter { sortAndFilter { name label options { label isSelected optionValue } } } } } }",
"variables": {
"context": {
"siteId": 1,
"locale": "en_US",
"currency": "USD",
"device": {
"type": "DESKTOP"
},
"identity": {
"duaid": "986e9653-0e36-413f-8fff-19bd7bddbe9b",
"expUserId": "-1",
"tuid": "-1",
"authState": "ANONYMOUS"
},
"debugContext": {
"abacusOverrides": [
],
"alterMode": "RELEASED"
}
},
"propertyId": "1173275",
"sortBy": "NEWEST_TO_OLDEST",
"filters": {
"includeRecentReviews": false,
"includeRatingsOnlyReviews": true
},
"pagination": {
"startingIndex": 10,
"size": 10
}
}
}
вот мой php код cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.expedia.com/graphql",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"operationName\": \"Reviews\",\n \"query\": \"query Reviews($context: ContextInput!, $propertyId: String!, $pagination: PaginationInput!, $sortBy: PropertyReviewSort!, $filters: PropertyReviewFiltersInput!) {propertyInfo(propertyId: $propertyId, context: $context) {reviewInfo(sortBy: $sortBy, pagination: $pagination, filters: $filters) { summary { superlative totalCount { raw formatted } reviewCountLocalized averageOverallRating { raw formatted } cleanliness { raw formatted } serviceAndStaff { raw formatted } amenityScore { raw formatted } hotelCondition { raw formatted } cleanlinessPercent cleanlinessOverMax serviceAndStaffPercent serviceAndStaffOverMax amenityScorePercent amenityScoreOverMax hotelConditionPercent hotelConditionOverMax ratingCounts { count { formatted raw } percent rating } lastIndex reviewDisclaimer } reviews { id ratingOverall superlative submissionTime { raw } title text locale author userLocation stayDuration helpfulReviewVotes negativeRemarks positiveRemarks locationRemarks photos { description url } managementResponses { id date displayLocale userNickname response } travelers themes { icon { id description } label } } sortAndFilter { sortAndFilter { name label options { label isSelected optionValue } } } } } }\",\n \"variables\": {\n \"context\": {\n \"siteId\": 1,\n \"locale\": \"en_US\",\n \"currency\": \"USD\",\n \"device\": {\n \"type\": \"DESKTOP\"\n },\n \"identity\": {\n \"duaid\": \"986e9653-0e36-413f-8fff-19bd7bddbe9b\",\n \"expUserId\": \"-1\",\n \"tuid\": \"-1\",\n \"authState\": \"ANONYMOUS\"\n },\n \"debugContext\": {\n \"abacusOverrides\": [\n \n ],\n \"alterMode\": \"RELEASED\"\n }\n },\n \"propertyId\": \"1173275\",\n \"sortBy\": \"NEWEST_TO_OLDEST\",\n \"filters\": {\n \"includeRecentReviews\": false,\n \"includeRatingsOnlyReviews\": true\n },\n \"pagination\": {\n \"startingIndex\": 10,\n \"size\": 10\n }\n }\n}",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/json",
"postman-token: 1a092745-0b00-5abb-3680-8fcd30eae915"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Я также попытался с помощью node js запроса вызова, но его возвращаемые данные в буфере и эти данные не удалось преобразовать в json формат
. Пожалуйста, помогите мне решить эту проблему