Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!