Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Curl setting headers origin

Tags:

curl

I want to set header origin when connecting to some url that not owned by me

is it possible to set server [HTTP_ORIGIN] via CURL

curl_setopt($ch,CURLOPT_HTTPHEADER,array('Origin: somevalue'));
like image 321
Onur Öztürk Avatar asked Sep 26 '14 12:09

Onur Öztürk


People also ask

What is Curlopt_returntransfer in curl?

CURLOPT_RETURNTRANSFER. true to return the transfer as a string of the return value of curl_exec() instead of outputting it directly. CURLOPT_SASL_IR. true to enable sending the initial response in the first packet. Added in cURL 7.31.

What is curl setopt?

The curl_setopt() function will set options for a CURL session identified by the ch parameter. The option parameter is the option you want to set, and the value is the value of the option given by the option. The value should be a long for the following options (specified in the option parameter):

Does PHP curl wait for response?

AFAIK, it will wait for a response before continuing running the script. Try adding if ($ret===false) echo curl_error($curl); after the $ret = curl_exec... line - it could be that the command is timing out waiting for a response.


1 Answers

Yes, that will work.

Keep in mind - if setting custom HTTP headers, you must set them all at the same time.

like image 84
Tim Krins Avatar answered Oct 12 '22 10:10

Tim Krins