ApiV2-GraphQL-Docs
ApiV2-GraphQL-Docs copied to clipboard
Get response status 'OK' but no data showed
Hi, I try to get data, using php example from here but it isn't send response data like the example. I'm using Laravel 5.7
here my code
public function anilist(){
$query = '
query ($id: Int) { # Define which variables will be used in the query (id)
Media (id: $id, type: ANIME) { # Insert our variables into the query arguments (id) (type: ANIME is hard-coded in the query)
id
title {
romaji
english
native
}
}
}
';
// Define our query variables and values that will be used in the query request
$variables = [
"id" => 15125
];
// Make the HTTP Api request
$http = new \GuzzleHttp\Client;
$response = $http->post('https://graphql.anilist.co', [
'json' => [
'query' => $query,
'variables' => $variables,
]
]);
dd($response);
}
and here the response
Response {#498 ▼
-reasonPhrase: "OK"
-statusCode: 200
-headers: array:15 [▼
"Server" => array:1 [▼
0 => "nginx"
]
"Content-Type" => array:1 [▼
0 => "application/json"
]
"Transfer-Encoding" => array:1 [▼
0 => "chunked"
]
"Connection" => array:1 [▼
0 => "keep-alive"
]
"Vary" => array:1 [▼
0 => "Accept-Encoding"
]
"Cache-Control" => array:1 [▼
0 => "no-cache, private"
]
"Date" => array:1 [▼
0 => "Tue, 15 Jan 2019 06:44:41 GMT"
]
"X-RateLimit-Reset" => array:1 [▼
0 => "1547534741"
]
"X-RateLimit-Limit" => array:1 [▼
0 => "90"
]
"X-RateLimit-Remaining" => array:1 [▼
0 => "89"
]
"Set-Cookie" => array:1 [▼
0 => "laravel_session=eyJpdiI6IlNzanJWOVdTaVU5a3gzbmZvTjZIRWc9PSIsInZhbHVlIjoiVXpKVmlxa2VXdVhxZ1FBTzNQRjcwTHFxT2FHb2RIV09sUnF1MVwvN21mWlBsd3ZYZGRnaDVtRCs3aXUzREVYUDZz ▶"
]
"X-Frame-Options" => array:1 [▼
0 => "SAMEORIGIN"
]
"X-XSS-Protection" => array:1 [▼
0 => "1; mode=block"
]
"X-Content-Type-Options" => array:1 [▼
0 => "nosniff"
]
"Access-Control-Expose-Headers" => array:1 [▼
0 => "X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset"
]
]
-headerNames: array:15 [▼
"server" => "Server"
"content-type" => "Content-Type"
"transfer-encoding" => "Transfer-Encoding"
"connection" => "Connection"
"vary" => "Vary"
"cache-control" => "Cache-Control"
"date" => "Date"
"x-ratelimit-reset" => "X-RateLimit-Reset"
"x-ratelimit-limit" => "X-RateLimit-Limit"
"x-ratelimit-remaining" => "X-RateLimit-Remaining"
"set-cookie" => "Set-Cookie"
"x-frame-options" => "X-Frame-Options"
"x-xss-protection" => "X-XSS-Protection"
"x-content-type-options" => "X-Content-Type-Options"
"access-control-expose-headers" => "Access-Control-Expose-Headers"
]
-protocol: "1.1"
-stream: Stream {#496 ▼
-stream: stream resource @308 ▼
wrapper_type: "PHP"
stream_type: "TEMP"
mode: "w+b"
unread_bytes: 0
seekable: true
uri: "php://temp"
options: []
}
-size: null
-seekable: true
-readable: true
-writable: true
-uri: "php://temp"
-customMetadata: []
}
}
Is there something that I miss?
I believe you need to do $response->getBody() to get the data of the response from guzzle
Hi @joshstar
Here's what I got using $response->getBody()
Stream {#589 ▼
-stream: stream resource @365 ▼
wrapper_type: "PHP"
stream_type: "TEMP"
mode: "w+b"
unread_bytes: 0
seekable: true
uri: "php://temp"
options: []
}
-size: null
-seekable: true
-readable: true
-writable: true
-uri: "php://temp"
-customMetadata: []
}