0
我需要连接到特定公司的API,他们提供了一个简单的API,您可以通过简单的URL获取数据。 例如:https://example.com?user=xxx&pass=xxx&data=specificdata有没有什么办法可以防止url注入?
我的问题是:
我有获取参数,并连接到API函数:
public function urlRequest($base_url, $company_id, $user_name, $password, $parameters) {
if (isset($base_url) && isset($company_id) && isset($user_name) && isset($password) && count($parameters) > 0) {
$url = "https://$base_url?compID=$company_id&user=$user_name&pass=$password&$parameters";
$response = file_get_contents($url);
$response = json_decode($response, true);
return $response;
}
}
1.Is有什么办法,我需要从URL注入保护和如果是这样,哪些功能可以与它相关? (htmlentities等...)
2.哪些字符不能在url中,我需要防范,这是类似于SQL注入?
它不是你的API,你不需要对传递给它的变量做任何事情。 –