Goldenapps
Forum Replies Created
-
Forum: Plugins
In reply to: [JSON API] how set posts per page ?hi
after your string in url add new code =====> count=190
for sample:https://localhost/Yoursite/?json=1&count=190
https://localhost/Yoursite/?json=get_posts&count=190Forum: Plugins
In reply to: [JSON API] Future postshi
go to plugin root and select singletons folder and find and open introspector.php
find your function and add new line below query. for sample:public function get_posts($query = false, $wp_posts = false) {
global $post, $wp_query;
$this->set_posts_query($query);
$output = array();
///// this line
$args = array_merge( $wp_query->query, array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish ) );query_posts( $args );
while (have_posts()) {
the_post();
if ($wp_posts) {
$new_post = $post;
} else {
$new_post = new JSON_API_Post($post);
}
$output[] = $new_post;
}
return $output;
}//////////or this line
$args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’ );Forum: Plugins
In reply to: [JSON API] How To Secure The json-api?Hi!
This Code For YOU . i love Json Api
Please Insert This Code To Your Theme Function.php
[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]
//////////////////////////////////////////////////////// <?php /* place in theme's functions.php file */ /* disable json api if api key not correct */ add_action('init','json_api_apikey_check' , 1 ); function json_api_apikey_check() { $api_key = 'yoursecterkey'; $base = get_option('json_api_base', 'api'); $this_url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; if ( ( isset($_REQUEST['json'] ) || strstr($this_url , $base.'/') ) && ( !isset($_REQUEST['apikey']) || $_REQUEST['apikey'] != 'yoursecterkey' ) ) { header("Location: https://www.yourdomain.com/"); exit; } } ?> ////////////////////////////////////////////////// dont forget to change 'yoursecterkey' dont forget to change 'https://www.yourdomain.com' https://domain.com/?json=1 --- not work and redirect to your domain home https://domain.com/?json=1&apikey=yoursecterkey ----- its work <!-- :D - JSON API IS BEST ->
Forum: Plugins
In reply to: [JSON API] To get limit on number of post !Hi!
follow this code:https://example.com/?json=get_recent_posts&count=2
count=2 or 10 or howmany
limit not work
Forum: Plugins
In reply to: [JSON API] Password protecting the JSON file?Hi!
This Code For YOU . i love Json Api
Please Insert This Code To Your Theme Function.php
////////////////////////////////////////////////////////<?php /* place in theme's functions.php file */ /* disable json api if api key not correct */ add_action('init','json_api_apikey_check' , 1 ); function json_api_apikey_check() { $api_key = 'yoursecterkey'; $base = get_option('json_api_base', 'api'); $this_url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; if ( ( isset($_REQUEST['json'] ) || strstr($this_url , $base.'/') ) && ( !isset($_REQUEST['apikey']) || $_REQUEST['apikey'] != 'yoursecterkey' ) ) { header("Location: https://www.yourdomain.com/"); exit; } } ?> ////////////////////////////////////////////////// dont forget to change 'yoursecterkey' dont forget to change 'https://www.yourdomain.com' https://domain.com/?json=1 --- not work and redirect to your domain home https://domain.com/?json=1&apikey=yoursecterkey ----- its work <!-- :D - JSON API IS BEST ->
[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code has now been damaged by the forum’s parser.]
Forum: Plugins
In reply to: [JSON API] Very slow response time on mobile appyou need unset other field.
for sample :
i show title and thumbnail and id in my main app.
so:
public function get_recent_posts() {
global $json_api;
$posts = $json_api->introspector->get_posts();
foreach ($posts as $post) {
unset($post->status);
unset($post->content);
unset($post->comments);
unset($post->attachments);
unset($post->thumbnail_images);
}
return $this->posts_result($posts);
}and get recent posts.very very fasting after this method
Forum: Plugins
In reply to: [JSON API] get all posts on one pageForum: Plugins
In reply to: [JSON API] How can i publish comment via apiForum: Plugins
In reply to: [JSON API] attachments in posts by category idhi1
for this:https://domain.com/?json=get_category_posts&slug=your-slug&include=id,title,attachments
dont forget change your-slug
Forum: Plugins
In reply to: [JSON API] How to get post by tag?hi!
follow this :https://domain.com/tag/yortag/?json=get_recent_posts
or
https://domain.com/tag/yortag/?json=get_posts
dont forget change yourtag to tagsname you need submit
Forum: Plugins
In reply to: [JSON API] How do I get nextpage ?https://domain.com/?json=get_recent_posts&page=1
https://domain.com/?json=get_recent_posts&page=2get &page=yourpage in string or url
Forum: Plugins
In reply to: [JSON API] Problem next page or get morehi!
for this:Forum: Plugins
In reply to: [JSON API] No Thumbnailfor this add code in function.php in your theme:
[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]
<?php function autoset_featured() { global $post; $already_has_thumb = has_post_thumbnail($post->ID); if (!$already_has_thumb) { $attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" ); if ($attached_image) { foreach ($attached_image as $attachment_id => $attachment) { set_post_thumbnail($post->ID, $attachment_id); } } } } //end function add_action('the_post', 'autoset_featured'); add_action('save_post', 'autoset_featured'); add_action('draft_to_publish', 'autoset_featured'); add_action('new_to_publish', 'autoset_featured'); add_action('pending_to_publish', 'autoset_featured'); add_action('future_to_publish', 'autoset_featured'); ?>
Forum: Plugins
In reply to: [JSON API] Remove unnecessary fields from json response1 methode by include in url:
https://www.yourdomain/api/get_post/?json=get_recent_posts&include=title,date,type,slug
/////////////////////////////////////////////////
2 methode add code in function:
in core.php find your methode and add this code before return
foreach ($posts as $post) {
unset($post->status);
unset($post->content);
unset($post->comments);
unset($post->attachments);
unset($post->thumbnail_images);
}// ——– for sample ————– //
public function get_recent_posts() {
global $json_api;
$posts = $json_api->introspector->get_posts();
foreach ($posts as $post) {
unset($post->status);
unset($post->content);
unset($post->comments);
unset($post->attachments);
unset($post->thumbnail_images);
}
return $this->posts_result($posts);
}Forum: Plugins
In reply to: [JSON API] Get posts with any post statushi
in singletons—>introspector.php —-> public function get_posts
add this code after $output = array();
—————————————
$args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘any’ );or your not need any can be change any to:
$args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish, pending’ );
publish – pending – draft – trash …