I have an educational website. When a student retrieves their result via URL, I’ve included an option to automatically add the result to their LinkedIn credentials. The code successfully retrieves all results except those queried from the URL. Below is the code snippet:
// Function to get the current URL
function getCurrentURL() {
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http";
$host = $_SERVER['HTTP_HOST'];
$uri = $_SERVER['REQUEST_URI'];
$queryString = isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '';
return $protocol . "://" . $host . $uri . $queryString;
}
$currentUrl = getCurrentURL();
// Generating LinkedIn URL
$linkedinUrl = "https://www.linkedin.com/profile/add?startTask=" . urlencode($Learner_Name) .
"&name=" . urlencode($Qualification_Name) .
"&organizationName=KNOWER%20INTERNATIONAL" . // Updated organization name
"&issueYear=" . date("Y", strtotime($Date_Awarded)) .
"&issueMonth=" . date("m", strtotime($Date_Awarded)) .
"&expirationYear=" . date("Y", strtotime($Date_Expiry)) .
"&expirationMonth=" . date("m", strtotime($Date_Expiry)) .
"&certUrl=" . $currentUrl . // Updated certificate URL to current page URL
"&certId=" . urlencode($Certificate_No); // Updated certificate ID
}
}
Can anyone please identify where is the problem. Thank You