Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

230
Vistas
how to hide an api key with php and js together

Im making API request from facebook graph api. i would like to hide the id and access token from client side. so i stored the access token on php then i got the data with js. but then i realized that it still shows on the console.log . how can i make it secure ? how to hide the api key? the data still show on the console so im not sure how i can hide thed data. i also have tried .env method but i know i can access from client side only on server side.

  let faceIDnum = sns_show_options.facebookID;
let faceID = faceIDnum.toString();
console.log(faceID);
 const businessIDface = faceID ;

this is how i did with js.

require_once __DIR__ . '/vendor/autoload.php';

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();


$snspostcount = get_option('post_count_number');
$sns_facebook_id_info = get_option('facebook_page_id' );

$sns_post_count = putenv("SNS_POST_TOTAL=$snspostcount");
$sns_post_count_val = getenv('SNS_POST_TOTAL');

$sns_facebook = putenv("SNS_FACEBOOK_ID=$sns_facebook_id_info");
$sns_facebook_id = getenv('SNS_FACEBOOK_ID');

// $nametag = $_ENV["SKDAI"];
var_dump($sns_post_count_val);

function wp_enqueue_javascript_scripts() {

    wp_register_script( 'javascript-js', get_template_directory_uri() . './js/index.js', array(), '1.0.0', true );
    wp_enqueue_script( 'javascript-js' );
    wp_localize_script( 'javascript-js', 'sns_show_options', 
    [
     'facebookID'=> getenv('SNS_FACEBOOK_ID')
  
     
    ]
    );
}
about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda