I am trying to write a simple plugin that fetches some data from an API endpoint. I am planning to read the api key from a shortcode, but didn't get that far yet. I wrote the following piece of code. The noob question I have is how do I even trigger the code so that I could debug it to see what happens ? If that's a simple question, the follow up would be how to read the api key …
My admin panel is very slow I've tried to debug the issue. I nailed it to the function wp_remote_post and an internal error message thrown by curl on this line return new WP_Error( 'http_request_failed', curl_error( $handle ) ); I wonder what would have happened if I uninstalled curl. Can WordPress use other mechanisms to make http requests or is curl required?
I'm somehow new to Wordpress and its API and while writing an simple Rest Service to an remote Server i have been asked to use the native wp_remote_X functions. Right now i have some trouble to distinguish between them both: wp_remote_post() wp_remote_request(). Does it make any difference which one to use or is the wp_remote_request an alias to missing wp_remote_delete() and wp_remote_update() ?
I'm trying to make some API POST requests via WordPress' own method i.e. wp_remote_post() Here is the sample code I'm using: $args = array ( 'sslverify' => false, 'headers' => [ 'Authorization: Bearer {API_KEY}', 'Content-Type: application/json' ], 'body' => array ( 'region' => 'USA', 'plan' => 1, 'label' => 'API Test', 'app_id' => 2 ) ); $response = wp_remote_post( "https://api.example.com/plans/create", $args ); $response = wp_remote_retrieve_body($response); error_log($response); But it returns me a 403 Forbidden error, Here are the details: <HTML> <head><title>403 …
On the internet I saw several plugins/services offering a kind of a 'magic login' link functionality. This allows users to sign in without a password but with a magic link. That made me wondering: If I want to implement this myself, how would I do this? I do not necessarily need to send emails, but just the process of getting a link/specific endpoint that signs a user in. Edit: after a little bit more digging I found the wp_signon() function, …
I made an api with nodejs and i'm trying to make some calls to it throught wordpress, all the requests works correctly but when i add a request body it is sent empty, i tried to search what was the problem but i found nothing that worked. I mean if i send this request $body = [ 'name' => 'Pixelbart', 'email' => '[email protected]', "password" => "Pass#your!word" ]; $body = json_encode( $body, TRUE ); echo $body; // here the body is …
I have several(5+) sites that are very similar in functionality. With that I have the same amount of functions.php files and child themes. What I'd like to do is have one common functions file and then a custom functions.php file for each individual site for more site-specific functionality. What is the best way to do this?
I want send a message to telegram whenever a form submitted. i am using gravity form plugin form. and it has the hook add_action( 'gform_after_submission', 'post_to_third_party', 10, 2 ); which will be call after form submitted. and i create a telegram bot and submit my url as webhook url base on instruction. here is my code: $url = $path."/sendmessage?chat_id=".$userID."&text=".'messaginggggg'; $request = file_get_contents($url); the problem is when i use the url in my browser it perfectly send notification to my bot …
I have a plugin that implements a REST API that needs to be notified when an admin adds one of my supported shortcodes to a page or post. I hook save_post with my function like this. add_action( 'save_post', 'detect_shortcodes'); However, when I update from the editor, it does an ajax call that instantiates my plugin. The first thing it does is determine whether to load public or admin hooks like this. if(is_admin()) { $this->define_admin_hooks(); } else { $this->define_public_hooks(); } Of …
I have a custom post type called 'event'. An event has multiple subpages like registration, speakers, contact us, etc. Currently the content is saved as one or more custom fields. I would like to have an url structure like events/{event_slug}/registration events/{event_slug}/speakers events/{event_slug}/contactus With each URL displaying the information from each custom field, respectively. Is there a way, we can achieve this in WordPress?
I'm developing a plugin, WP SoundSystem, that makes Wordpress rest requests to my remote API api.spiff-radio.org. That API is scraping content on the web. Which means that it might be slow to get the data. (EDIT:that data is just plain text tracklists) So WP SoundSystem plugin requests data on api.spiff-radio.org... ...api.spiff-radio.org scrapes the web... ...api.spiff-radio.org returns a response... ...WP SoundSystem plugin gets the response WHICH might be quite slow. I already set a 20 seconds timeout (default is 5) when …
I try to send a request with the function wp_remote_request and it is not accepted (Note the port at URL) When I download the port it is accepted Where's the problem? tish is the code: $args = array( 'body' => array( 'key' => 'value' ) ); wp_remote_request('http://exemple.com:8001/page', $args);
I'm trying to build a Wordpress plugin that is an API which can be queried from remote websites. I want to secure it with JWT web tokens, so I did install the JWT Authentication for WP REST API plugin. I read this article to configure it, and have a working setup (checked in Postman). So I have my API website with JWT working. Now, I want to request that API from the client website. I need a token from the …
I'm trying to make calls to a JSON API inside my wordpress theme. I tried with the cURL option, making a custom function and things works as it should but I wanted to use the built-in wordpress functions and with the same parameters I keep getting an error "Invalid request header" here are my parameters: $payload = array ( 'httpversion' => '1.0', 'headers' => array ( 'Content-type' => 'application/json', 'Accept' => 'application/json; charset=utf-8', 'Authorization' => 'Basic ' . base64_encode( $login …
I want to install a plugin using wp-cli (or anything else) on a WordPress based website. I have URL, admin-user, admin-pass only. (no FTP/ssh). I want to do it programmatically, without going into the browser. I am able to do so on my local WordPress install.
I use WordPress rest API for app communication with my site in need update post view counter when HTTP get API. I search a lot but nothing found about it, in a tutorial "Find popular posts with the WordPress REST API" view counter update when call HTTP get API URL but it's in custom endpoint but I need this update function in rest API default endpoint the code for popular post custom endpoint : add_action( 'rest_api_init', function () { register_rest_route( …
I try to send async multiple requests with proxy option by built-in WP Class Requests, but it's not working. $options = array( 'proxy' => $proxy ); Single Request, it's working, so the proxy itself is working properly. $s = Requests::request($link1, array(), array(), 'GET', $options); The result of var_dump($s): object(Requests_Response)[1637] public 'body' => string '<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're …
I am writing a plugin that syncs data from a third party service to custom post types in wordpress via HTTP/SOAP. There will be the option to run it on an interval (using wP_cron functions) but I also want to include a 'Sync' button to be able to manually pull in or update data without having to wait for the next time the cron runs. I have an options page for the plugin page setup using Wordpress's Settings API, which …
I normally use this argument to prevent errors with wp_remote_get and wp_remote_post array( 'sslverify' => false ) For security reasons I would like to set it to true (or remove it since the default is true). Should I expect any problems by doing that?
I'm developing a payment gateway for Wordpress. I should send the data to a third party and get the confirmation code (and other info) from them. The problem is that they don't return this confirmation code as a direct response to my POST request. Instead, they process it, and send a POST request to a URL that I can specify. Because of this, I can't use the wp_remote_post. How can I implement this, and if possible, ensure that the user …