简体   繁体   中英

Curl command to PHP script

So I need to create a Curl Script in my PHP and I am confused I don't know that much Curl (As in I only know how to copy and paste and cross my fingers).

The Curl Command is

curl https://website.com/v1/route -u key-of-power

so far I have

                $ch = curl_init();
                curl_setopt ( $ch, CURLOPT_URL, https://website.com/v1/route);
                curl_setopt ( $ch, CURLOPT_POST, 1 );
                curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
                $payment_response = curl_exec ($ch);
                curl_close ($ch);

so I need to know where key-of-power goes so my curl can pass.

Thank in advance!!

curl_setopt($ch, CURLOPT_USERNAME, "$username") will do it. More detail is here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM