Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

256
Visualizações
Get index value of Json by using curl and change the value(replace) with the other value. am not getting the index value, so that i can replace

am using webform in drupal and trying to convert json which is default generated by the rest api to custom json by using the curl operation in custom module, to change the some key value like title with label and so on...

am not getting how to do? can any body help here..

<?php
 
namespace Drupal\custom_rest_services\Controller;


use Symfony\Component\HttpFoundation\JsonResponse;


class custom_rest_servicesController {
  public function converter_json_formio() { 
    
    

    return new jsonresponse( [

      'data' => $this->getResult(),
      'method' => 'GET',

    ]
    );
  }
  
  private function getResult(){
    

    $curl = curl_init();
    
    curl_setopt_array($curl, array(
      CURLOPT_URL => 'http://localhost/install-dir/web/webform_rest/feedback_13/fields',
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => '',
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => 'GET',
      CURLOPT_HTTPHEADER => array(
        'Authorization: Basic YWRtaW46QWRtaW5AMTIz'
      ),
    ));
    
    $result = curl_exec($curl);

    if (curl_errno($ch)) { echo curl_error($ch); }
 
   
    else {
      
      $decoded = json_decode($result);
      print_r($decoded); // ARRAY
    }
curl_close($curl);

// return  $result;
  }

}

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda