How to set status codes such as 401 and 403?

The same way you would in any other PHP program: header(“HTTP/1.1 401 Unauthorized”); exit; WordPress has special handling for 404 because there’s a 404 template. Usually if something happens such as a 401, there is no special template, but you can make use of wp_die which will show a message in a simple UI header(“HTTP/1.1 … Read more

Cant Access Website – Changed HTTP to HTTPs

By default web servers / your hosting serves files from HTTPS from a separate folder. This means that there are actually two directories on the server for hosting your website files: For example public_html – the standard “public” folder for HTTP requests private_html – the standard “private” folder for HTTPS requests (e.g. secure content) I … Read more

problem using WP_Http with paypal nvp api

Looking at your original code, I’d say you need to add the sslverify arg. And on a side note, use the HTTP functions available, rather than instantiating the class yourself (you shouldn’t have to load the class manually). wp_remote_post( $url, array( ‘sslverify’ => false, // this is true by default! ‘body’ => array( ‘METHOD’ => … Read more

How to get title tag of an external page with http api?

here is a function i have for that: function get_page_title($url){ if( !class_exists( ‘WP_Http’ ) ) include_once( ABSPATH . WPINC. ‘/class-http.php’ ); $request = new WP_Http; $result = $request->request( $url ); if( is_wp_error( $result ) ) return false; if( preg_match(“#<title>(.+)<\/title>#iU”, $result[‘body’], $t)) { return trim($t[1]); } else { return false; } } Usage: $title = get_page_title(‘http://www.google.com’); … Read more