Response in reCAPTCHA comes back as a none object. PHP Symfony

I am stuck here guys I am using symfony 3.4 and I am making an api call to googles reCAPTCHA and when I decode my json response and return a value that is suppose to come back from googles api I get an error stating that it isnt a object, my code in my controller is here. I blocked out my secret for obvious reasons.

     * @Route("/", name="homepage")
    public function indexAction(Request $request) {

    try {
        $formModel = new Contact();
    } catch (\Exception $exception) {
        throw new \RuntimeException('an error occurred');
    $form = $this->createForm(ContactFormType::class, $formModel);

    if ($form->isSubmitted() && $form->isValid() && $this->captchaverify($request->get('g-recaptcha-response'))) {
        $em      = $this->getDoctrine()->getManager();
        $contact = $form->getData();

        return new JsonResponse([
            'status' => 'ok',
    } elseif ($form->isSubmitted()) {
        return new JsonResponse([
            'status'   => 'error',
            'errors'   => Utility::getErrorsFromForm($form),
    if($form->isSubmitted() &&  $form->isValid() && !$this->captchaverify($request->get('g-recaptcha-response'))){

                'Captcha Require'

        return $this->render('@App/form.html.twig', [
            'form' => $form->createView(),

function captchaverify($recaptcha){
     $url = "";
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, array(
     $response = curl_exec($ch);
     $data = json_decode($response);

 return $data->success;

If you are facing that kind of issue to not getting the response the reCaptcha that you can set by the process of the settings easily from some of the few techniques which you can check on the Epson printer recovery mode for that reason that kind of issue can also be solved.

Please do not change your Category back to General. You are seeking help with PHP, so the appropriate category is Help.

In most Web forms, you usually have two files: the form itself with the fields and the file with the script to process the inputs to the form. For more visit HP Support Number

Hey, This is a great article. I was searching for the same and I found the best content here. Thanks for sharing the info. keep on doing the great work.
Sage Live support

This site has helped me personally and helped me help others. I am so glad you decided that you need to pass it on because we all need it passed on. Very interesting. If you have any problems, contact HP Support Assistant

I’ve started my coding by using your website. The website contains really great quality content. In case of any tech help contact geek squad support.