How to use API in wordpress

I would like to connect one Razorpay payment API using WordPress, the API has an authentication token using a username and password.

Is there any built-in functionality available in WordPress to call a call and answer?

+5
source share
1 answer

you can use wp_remote_get()

eg

 wp_remote_get( 'http://www.example.com/index.php?action=foo', array( 'timeout' => 120, 'httpversion' => '1.1' ) ); 

You can also manage all query parameters, such as headers and body data.

Default use

 global $wp_version; $args = array( 'timeout' => 5, 'redirection' => 5, 'httpversion' => '1.0', 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url(), 'blocking' => true, 'headers' => array(), 'cookies' => array(), 'body' => null, 'compress' => false, 'decompress' => true, 'sslverify' => true, 'stream' => false, 'filename' => null ); 

Link: Additional Information

+7
source

Source: https://habr.com/ru/post/1272868/


All Articles