Hiding WordPress REST endpoints from public viewing using Basic Authentication

Here is my solution. Inside the callback function I validate Authorization from the header like this: function callback_function($data) { //Get HTTP request headers $auth = apache_request_headers(); //Get only Authorization header $valid = $auth[‘Authorization’]; // Validate if ($valid == ‘Basic Base64UsernamePassword’) { //Do what the function should do } else { $response=”Please use a valid authentication”; … Read more

how to fetch posts from Api in chunks or parts?

You’d probably want to wrap what you’ve done up there into a function and do something like. for ( $counter = 0; $counter <= 1906; $counter += 20) { $responseURL = ‘https://api.hubapi.com/content/api/v2/blog-posts?hapikey=’ . $apiKey . ‘&archived=false&limit=20&offset=” . $counter; $response = wp_remote_get($responseURL, $getArgs); process_API_results($response); $restcounter++; if($restcounter == 6) { // works out to 120 posts then … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)