php curl设置代理
A few months back, I shared with you how to download the contents of a URL and execute a HTTP POST transmission using PHP cURL. For security purposes, some hosts require that a common user agent be present in the POST. If an unacceptable user agent is given, the POST is ignored. Luckily, cURL allows us to "spoof" the server using any user agent we choose:
几个月前,我与您分享了如何下载URL的内容以及如何使用PHP cURL 执行HTTP POST传输 。 为了安全起见,某些主机要求POST中包含一个公共用户代理。 如果给出了不可接受的用户代理,则忽略POST。 幸运的是,cURL允许我们使用我们选择的任何用户代理来“欺骗”服务器:
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
A little sneaky but it could get you out of a jam at some point!
有点偷偷摸摸,但在某些时候它可能使您摆脱困境!
php curl设置代理