Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在web/mobile中调用远程restful api时如何保护用户名密码?_Rest_Restkit - Fatal编程技术网

在web/mobile中调用远程restful api时如何保护用户名密码?

在web/mobile中调用远程restful api时如何保护用户名密码?,rest,restkit,Rest,Restkit,这是我的php脚本,用来调用远程restful api,用户名和密码是用源代码硬编码的 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://localhost/m1/m1apiserver/public/api/login"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "email=elson%40bla.com&a

这是我的php脚本,用来调用远程restful api,用户名和密码是用源代码硬编码的

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"http://localhost/m1/m1apiserver/public/api/login");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
        "email=elson%40bla.com&password=bla");

// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$json = curl_exec ($ch);

curl_close ($ch);

$j = json_decode($json);
// further processing ....
if ($j->token) {
    //echo $j->token;
    $output = file_get_contents("http://localhost/m1/m1apiserver/public/api/product?token=".$j->token);
    echo $output;
}
但是有什么技术可以保护用户名密码吗?

请定义“安全”。这是一个沟通问题吗?是否存在存储问题?请定义“安全”。这是一个沟通问题吗?这是存储问题吗?