2

I am trying send a curl request to a URL which requires HTTP_ORIGIN to be set, I have this so far...

$headers = array(
    'Origin: www.myorigin.com',
);

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_HEADER, true,
    CURLOPT_HTTPHEADER, $headers,
    CURLOPT_URL => 'http://www.example.com',
    CURLOPT_USERAGENT => 'Sample Request'
));

$resp = curl_exec($curl);

curl_close($curl);

This is giving me an error on the server side of Undefined index: HTTP_ORIGIN so it doesn't look like it is passing the origin through.

Have I set this up correctly?

1 Answer 1

2

You use coma , instead of => into your array, so CURLOPT_HTTPHEADER is a value of the array, instead of a key.

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_HEADER => true, // << HERE
    CURLOPT_HTTPHEADER => $headers, // << HERE
    CURLOPT_URL => 'http://www.example.com',
    CURLOPT_USERAGENT => 'Sample Request'
));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.