|
刚看了看代码,也不是太了解,只能举个小例子了,实现api登录
$uri = "https://localhost/opencart/index.php?route=api/login";
$keys = array(
'username' => '你的api用户名',
'password' => '你的api密码串i'
);
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $uri );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $keys );
$return = curl_exec ( $ch );
curl_close ( $ch );
print_r($return); |
|