curl命令行和代码之间的区别

时间:2016-06-28 13:58:30

标签: php curl

有什么区别:

curl -v --data "username=username&password=password&sessionDataKey=5c4a5bb8-eb14-44a0-a745-50f54024a1b2" https://api.toonapi.com/commonauth/

$url = 'https://api.toonapi.com/commonauth/';
    $session_key = $this->curlSessionKey();
$data_string = 'username=' . $username . '&password=' . $password . '&sessionDataKey=' . $session_key;
  //json_encode($data);


$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/x-www-form-urlencoded',
    'Content-Length: ' . strlen($data_string))
);

我似乎无法弄清楚我做错了什么

0 个答案:

没有答案