我想将一个 Razorpay 支付 API 与 WordPress 连接,API 具有使用用户名和密码的身份验证 token 。
WordPress 中是否有任何内置功能可用于进行调用和处理响应?
最佳答案
你可以使用wp_remote_get()
例如
wp_remote_get( 'http://www.example.com/index.php?action=foo', array( 'timeout' => 120, 'httpversion' => '1.1' ) );
您还可以控制所有请求参数,例如 header 和正文数据。
默认用法
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
);
引用:More info
关于php - 如何在wordpress中使用API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46924779/