PHP cURL 自定义 header

标签 php curl

我想知道是否/如何在 PHP 中向 cURL HTTP 请求添加自定义 header 。我正在尝试模拟 iTunes 如何抓取艺术品并使用这些非标准标题:

X-Apple-Tz: 0
X-Apple-Store-Front: 143444,12

如何将这些 header 添加到请求中?

最佳答案

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'X-Apple-Tz: 0',
    'X-Apple-Store-Front: 143444,12'
));

http://www.php.net/manual/en/function.curl-setopt.php

关于PHP cURL 自定义 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8115683/

相关文章:

php - 在 PHPcurl_multi 中,是否有与curl_getinfo() 等效的函数来获取curl_multi_exec() 的HTTP 响应代码?

php - 使用curl为GET方法添加变量

php - 使 cURL 输出 STDERR 到文件(或字符串)

php - 想要将 css 选择器与表中所有 TD id 的变量一起使用

javascript - 根据其他表单字段填写选择选项输入

javascript - 使用 php curl 进行长轮询

php - 在 php 7 (ubuntu14.04) 中安装 cURL

php - 多个复选框内的 codeigniter

php - Moodle 中不存在表 'mdl_sessions'

php - 如何在 PHP 中使用 COM 对象获取 UTF-8 字符串?