我是一名初学者,正在构建一个rest api和身份验证。 我刚刚阅读下面的,并解释非常简单的设置:Laravel rest api身份验证
laravel 5 rest api basic authentication
在文章解释不与标题或URL中的用户名发送和密码底部。
我的问题是基本的:任何人都可以给我一个例子如何使用上面的例子的cUrl请求?
例如:
$service_url = 'http://example.com/api/conversations';
$curl = curl_init($service_url);
$curl_post_data = array(
'user' => '[email protected]',
'passw' => '1234'
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
$curl_response = curl_exec($curl);
curl_close($curl);