vbakare
Forum Replies Created
-
Forum: Plugins
In reply to: comments using JSON apiuse following URL for commenting on post
before that you will have to enable Respond controller from
wordpress->settings->json API settingsForum: Plugins
In reply to: [JSON API] [Plugin: JSON API] How to add a comment or post?I modified the post.php controller file to authenticate using user name password.
I wanted to create post from my intranet J2EE application , and was not allowed to retrieve actual passwords of the User from Active Directory.
So I created a Super User who has access to create post just for authentication and modified the authenticate() method from post.php to read one more parameter ‘wpAuthUser’ and let the ‘Author’ parameter used for post author only.[Code moderated as per the Forum Rules. Please use the pastebin]
here is the URL to create post with login
https://localhost/wordpress/api/?json=create_post&nonce=12313&status=publish&title=VB&content=VB_CONTENT&author=vb&user_password=admin&wpAuthUser=adminyou can also refer below link for original concept.
https://github.com/dphiffer/wp-json-api/pull/3Forum: Plugins
In reply to: [Plugin: JSON API] How do I authenticate as a WP user to do a create_post?Ok. I got it working. I modified the post.php controller file to authenticate using user name password.
I wanted to create post from my intranet J2EE application , and was not allowed to retrieve actual passwords of the User from Active Directory.
So I created a Super User who has access to create post just for authentication and modified the authenticate() method from post.php to read one more parameter ‘wpAuthUser’ and let the ‘Author’ parameter used for post author only.private function authenticate() {
global $json_api;
if ($json_api->query->wpUser && $json_api->query->user_password) {
$user = wp_signon(array(‘user_login’ => $json_api->query->wpUser, ‘user_password’ => $json_api->query->user_password));
if (get_class($user) == ‘WP_Error’) {
$json_api->error($user->errors);
} else {
if (!user_can($user->ID,’edit_posts’)) {
$json_api->error(“You need to login with a user capable of creating posts.”);
}
}
} else {
if (!current_user_can(‘edit_posts’)) {
$json_api->error(“You need to login with a user capable of creating posts.”);
}
}
}you can also refer below link for original concept.
https://github.com/dphiffer/wp-json-api/pull/3Forum: Plugins
In reply to: [Plugin: JSON API] How do I authenticate as a WP user to do a create_post?Anybody have solution for this? I am trying to create/submit response to post using json api and it is not allowing me to do so. Authentication is required.
Help please….