So I have been having trouble implementing Recaptcha v2
Here is my form code
<form action="upload.php" method="POST" enctype="multipart/form-data">
<div id="html_element"></div>
<input type="file" name="file" style="font-family:'PSR';">
<button type="submit" name="submit">Upload</button>
<div class="g-recaptcha" data-sitekey="key" data-theme="dark"></div>
And this is the recaptcha part of code (same file but tried splitting into 2 before)
$secret = 'the secret';
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=". $secret."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
$googleobj = json_decode($response);
echo $googleobj;
$verified = $googleobj->success;
if($verified === true)
{
Whatever I do $verified always returns false. The echo part was me trying to debug but that has given me another error followed by a HTTP error 500.
PHP Recoverable fatal error: Object of class stdClass could not be converted to string
Vardump of $_POST['g-recaptcha-response'] returns
string(334) "03AF6jDqXmI34YXuv1jIkgqHFo7TcjWbOq4-LJ_aTBRyzDld5BytgSe4ck_dolLm3C9CUzxela7LWa7hYJeJfEBONPPsx3ol7Ch-7SY8I9WyAFEy-iiGqwxZBY41gCSw7dfT42doqg-FIxwZweLOsH5YEf8i-L2QgkAJEd_PrWc9m2Uf6ZNbTDqCNr3VFqF8_0I-gS0Rhj9Z5XXwQLC9LeNfSWhI0DkpYNgK-hO4nGfEsaZT0PMlAg9DbHh9CzKDUzPpguVxz1zw0FP8CgwyBd9sgzpR4LfAoPuduGj0Z0wVcqbQ-CTifFtH7kCJuNG6bCDEufYfntj-8L"
Sorry if this is very basic stuff but im new to PHP