我想知道如何/如何可以自定义标头添加到PHP中的cURL HTTP请求。 我试图模仿iTunes抓取艺术品,它使用这些非标准的标题: X-Apple-Tz: 0 X-Apple-Store-Front: 143444,12 我怎样才能将这些标题添加到请求?
我正在构build一个应用程序(在使用Dev-C ++的Windows上),我希望它下载一个文件。 我正在做这个使用libcurl(我已经安装了使用packman的源代码)。 我发现一个工作的例子( http://siddhantahuja.wordpress.com/2009/04/12/how-to-download-a-file-from-a-url-and-save-onto-local-directory-in- c-using-libcurl / ),但下载完成后不会closures文件。 我希望有人来举例说明如何下载文件,无论是在C或C + +。 提前致谢!
我想在我的C#控制台应用程序中进行下面的curl调用: curl -d "text=This is a block of text" http://api.repustate.com/v2/demokey/score.json 我试图像这里发布的问题,但我不能正确填写属性。 我也尝试将其转换为常规的HTTP请求: http://api.repustate.com/v2/demokey/score.json?text="This%20is%20a%20block%20of%20text" 我可以将cURL调用转换为HTTP请求吗? 如果是这样,怎么样? 如果没有,我怎样才能正确地从我的C#控制台应用程序进行上述cURL调用?
当我向服务器发送请求时,我想查看curl所做的请求头。 我如何检查?
其实我有两个问题。 (1)如果我只检索标题而不是使用php和curl进行全页检索,那么在远程服务器上使用的处理能力或带宽有没有减less? (2)由于我认为,我可能是错误的,对第一个问题的答案是YES ,我试图得到最后的修改date或If-Modified-Since头文件只是为了比较它的时间date本地存储的数据,所以我可以,如果它已被改变,存储在本地。 但是,我的脚本似乎无法获取该信息,我得到NULL ,当我运行这个: class last_change { public last_change; function set_last_change() { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "http://url/file.xml"); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_FILETIME, true); curl_setopt($curl, CURLOPT_NOBODY, true); // $header = curl_exec($curl); $this -> last_change = curl_getinfo($header); curl_close($curl); } function get_last_change() { return $this -> last_change['datetime']; // I have tested with Last-Modified & If-Modified-Since […]
我有一个网站使用cURL(最新版本)连接到安全网关进行付款。 问题是cURL总是返回0长度的内容。 我只收到标题。 只有当我设置cURL返回标题。 我有以下的标志。 curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_URL, $gatewayURI); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_POST, 1); 返回的头是 HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Tue, 25 Nov 2008 01:08:34 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Content-Length: 0 Content-Type: text/html Set-Cookie: ASPSESSIONIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; path=/ Cache-control: private 我也尝试cURL'ing不同的网站,他们返回的内容很好。 […]
我不熟悉cURL,很难为它find好的资源。 我想要做的是login到远程站点,通过curl做login表单,然后发回它是成功的。 我的代码似乎不工作,只试图显示网站的主页。 $username="mylogin@gmail.com"; $password="mypassword"; $url="http://www.myremotesite.com/index.php?page=login"; $cookie="cookie.txt"; $postdata = "email=".$username."&password=".$password; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt ($ch, CURLOPT_REFERER, $url); curl_setopt […]
在PHP中,我在许多PHP项目中看到了cURL这个词。 它是什么? 它是如何工作的? 参考链接:( 什么是PHP中的cURL? )
我正在尝试编写一个bash脚本进行testing,它需要一个参数并通过curl将其发送到网站。 我需要URL的编码值,以确保特殊字符处理正确。 什么是最好的方法来做到这一点? 到目前为止,这是我的基本脚本: #!/bin/bash host=${1:?'bad host'} value=$2 shift shift curl -v -d "param=${value}" http://${host}/somepath $@
我在本地开发环境中使用WAMP,并试图收取信用卡,但收到错误消息: cURL错误60:SSL证书问题:无法获取本地颁发者证书 我在Google上search了很多,很多人build议我下载这个文件: cacert.pem ,把它放在某个地方,并在我的php.ini中引用它。 这是我的php.ini中的一部分: curl.cainfo = "C:\Windows\cacert.pem" 但是,即使重新启动我的服务器多次并更改path后,我也会得到相同的错误消息。 我使用Apache模块中的WAMP并启用了ssl_module。 从PGP扩展我有php_curl启用。 还是一样的错误信息。 为什么会这样呢? 现在我正在关注此修复: 如何修复PHP CURL Error 60 SSL 这表明我将这些行添加到我的cURL选项中: curl_setopt($process, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem'); curl_setopt($process, CURLOPT_SSL_VERIFYPEER, true); 我在哪里添加选项到我的cURL? 显然不是通过命令行,因为我的CLI没有find命令“curl_setopt” 编辑 这是我正在运行的代码: public function chargeStripe() { $stripe = new Stripe; $stripe = Stripe::make(env('STRIPE_PUBLIC_KEY')); $charge = $stripe->charges()->create([ 'amount' => 2900, 'customer' => Input::get('stripeEmail'), 'currency' => […]