使用CURL发送标头并接收Json数据 - PHP

时间:2017-02-16 14:19:39

标签: php json curl

我收到错误,不确定这是否是标头错误?当我使用具有相同标题和URL

的Postman时,Feed可以100%工作
$url    = 'http://x.x.x.x/api/slot/0/io/';
$headers = array(
        'Accept:vdn.v1',
        'Content-Type:application/json'

    );

 $ch = curl_init();

    // Now set some options (most are optional)

    // Set URL to download
    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    // Set a referer
    curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");

    // User agent
    curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");

    // Include header in result? (0 = yes, 1 = no)
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $headers

    // Should cURL return or print out the data? (true = return, false = print)
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Timeout in seconds
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);

    // Download the given URL, and return output
    $output = curl_exec($ch);

    // Close the cURL resource, and free system resources
    curl_close($ch);

print_r($output);exit;

这是我尝试过的,我的PHP代码

var relList = context.rel.Where(x => x.parentXID = 123);

var result = context.students.Where(x => relList.studentXID.Contains(x.studentid));

1 个答案:

答案 0 :(得分:0)

我从

更改了标题
assert capture_io([input: "y"], fn -> confirm("Question") end) == "Question"

$headers = array(
        'Accept:vdn.v1',
        'Content-Type:application/json'

    );

排序所有问题