$url = "https://www.google.com/?q="; $post_array = array( "query" => "imbobby", ); $header_authorization = ""; $response = wp_remote_get( $url, array( // wp_remote_post 'method' => 'GET', // 'POST' 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array( // 'Authorization' => 'Bearer ' . $header_authorization, ), 'body' => $post_array, 'cookies' => array() ) ); if ( is_wp_error( $response ) ) { $error_message = $response->get_error_message(); echo "Something went wrong: $error_message"; } else { echo wp_remote_retrieve_body($response); //echo 'Response:<pre>'; //print_r( $response ); //echo '</pre>'; }Related Keywords: Developer, How-to, Solved, wp_remote, wp_remote_get, wp_remote_post, WordPress CURL
喜歡這篇文章嗎?
(暫時未有評分)
Loading...
(暫時未有評分)
Loading...