PHP cURL自定义标头 [英] PHP cURL custom headers

查看:131
本文介绍了PHP cURL自定义标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

$

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

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


I'm wondering if/how you can add custom headers to a cURL HTTP request in PHP. I'm trying to emulate how iTunes grabs artwork and it uses these non-standard headers:

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

How could I add these headers to a request?

解决方案

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自定义标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆