Any ideas how I can approach logging into a Wordpress site using a username and password stored within an iPhone app? I am looking for a pointer in the right direction from someone who's done this bef开发者_运维知识库ore, because I didn't find many details on the web.
You could set your WP site to use wp_signon() ( http://codex.wordpress.org/Function_Reference/wp_signon ) to receive the credentials and sign you in right away.
Could be something like:
<?php
//First check useragent/nonce to make sure it's coming from your phone/app
//Now get credentials and log in
$creds = array();
$creds['user_login'] = $_POST['usr'];
$creds['user_password'] = $_POST['pwd'];
$creds['remember'] = true;
$user = wp_signon( $creds, false );
if ( is_wp_error($user) ){
echo $user->get_error_message();
} else {
//do your stuff
}
?>
Not super sophisticated, but could be a start =)
Hope that helps!
精彩评论