用PHP和Curl绘制ql图
我已经进行了身份验证,甚至在postman中测试了我的查询,因为我似乎错过了查询返回用PHP和Curl绘制ql图,curl,graphql-php,Curl,Graphql Php,我已经进行了身份验证,甚至在postman中测试了我的查询,因为我似乎错过了查询返回 function generate_edge_curl(){ $endpoint = $this->get_endpoint(); $auth_token = $this->token->get_token(); $ch = curl_init($endpoint); curl_setopt($ch, CURLOPT_POST, true); curl_
function generate_edge_curl(){
$endpoint = $this->get_endpoint();
$auth_token = $this->token->get_token();
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'x-amz-user-agent: aws-amplify/2.0.1',
'content-type: application/json',
'Authorization: '.$auth_token['access_token'],
));
return $ch;
}
function get_bidders(){
$ch = $this->generate_edge_curl();
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"query":"{
auctionInfo(id: \'alldal\') {
bidders {
list {
companyAmsId
companyName
firstName
lastName
badgeNum
bidderType
}
}
}
}"}');
$output = curl_exec($ch);
curl_close($ch);
var_dump($output);
}
返回
string(133) "{
"errors" : [ {
"message" : "Invalid JSON payload in POST request.",
"errorType" : "MalformedHttpRequestException"
} ]
}"
我是一个全新的人,我在这里遗漏了什么?所以经过一些挖掘和多次失败的尝试,这就是我想出的行之有效的方法
function generate_edge_curl(){
$endpoint = $this->get_endpoint();
$auth_token = $this->token->get_token();
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'x-amz-user-agent: aws-amplify/2.0.1',
'content-type: application/json',
'Authorization: '.$auth_token['access_token'],
));
return $ch;
}
function get_bidders(){
$query = <<<'GRAPHQL'
query {
auctionInfo(id: "alldal") {
bidders {
list {
companyAmsId
companyName
firstName
lastName
badgeNum
bidderType
}
}
}
}
GRAPHQL;
$ch = $this->generate_edge_curl();
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['query' => $query]));
$output = curl_exec($ch);
curl_close($ch);
var_dump($output);
}
函数生成边卷曲(){
$endpoint=$this->get_endpoint();
$auth_token=$this->token->get_token();
$ch=curl_init($endpoint);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HTTPHEADER,数组(
“x-amz-user-agent:aws amplify/2.0.1”,
'内容类型:application/json',
'授权:'.$auth_token['access_token'],
));
返回$ch;
}
函数get_bidders(){
$query=接球不错!也遇到了同样的问题。谢谢!
$query = <<<'GRAPHQL'
query {
auctionInfo(id: "alldal") {
bidders {
list {
companyAmsId
companyName
firstName
lastName
badgeNum
bidderType
}
}
}
}
GRAPHQL;