我需要通过PHP中的JSON Endpoint接收数据,有人可以帮助我吗?
我如何通过以下方式接收数据:
curl https://formz.herokuapp.com/api/forms/e382704d/submissions -H'授权:令牌令牌=" xxxxxxxxxxxxx"'
答案 0 :(得分:0)
使用curl
和CURLOPT_HTTPHEADER
$ch = curl_init();
$headers = array('Authorization: Token token="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"');
curl_setopt($ch, CURLOPT_URL,"https://formz.herokuapp.com/api/forms/e382704d/submissions");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec ($ch);
curl_close ($ch);
print $output;
应该给你输出
答案 1 :(得分:0)
我找到了解决方案
就是这样。
$access_key = 'TOKEN HERE';
$curl = curl_init( 'https://formz.herokuapp.com/api/forms/e382704d/submissions' );
curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Authorization: Token ' . $access_key ) );
curl_exec( $curl );