Get JSON Events List
-
Hi,
I bought a mobile App Template from MyAppTemplate to build an app from my wordpress site (with EM plugin).
Android app receive events list surfing on a link and using JSON:
you can see author example fromhttp://www.myapptemplates.com/events/api/getEvents
With this link you visualize JSON events list example.
How did the author do to link events page to API?
I asked to him, but he didn’t answer…There’s some that can help me to get JSON EVENTS LIST?
Thank you
-
I am not part of support team…
But do have a little experience pulling data from other JSON’s.
Putting my own JSON out is something I have looked at…
you might try reading…Which I believe implies you need a plugin to generate the JSON..
https://wordpress.org/plugins/rest-api/
Would love to hear how it works out, please keep us informed.
WARNING !!!!!
https://wordpress.org/plugins/rest-api/
I just did a test on my local development machine !!!
I am running WP 4.3.1..
I GET..
Fatal error: Call to undefined function get_rest_url() in C:\Abyss Web Server\htdocs\wordpress\wp-content\plugins\rest-api\extras.php on line 24see this post !
https://wordpress.org/support/topic/undefined-function-11?replies=4I tried this on my the same machine..
https://wordpress.org/plugins/json-api/
And it works… but does not appear to show Events !
The plugin may need to be configured for “custom” posts.OK ! I have success… you owe me a special Italian Beer !
see this post..
https://wordpress.org/support/topic/end-point-for-custom-post-type-in-v2?replies=13Particularly…
‘show_in_rest’ => true,Needs to be added when a Custom Post Type is registered..
It looks like Events Manager is not doing this at this time..On my local development machine.. on a test site using WP 4.4
and this plugin…
https://wordpress.org/plugins/rest-api/ which is Version 2 needs WP 4.4Thusly.. ‘show_in_rest’ => true, needs to be added.
What I did…
In the file…
em-posts.phpSearch for the lines that have…
‘has_archive’ => get_option(‘dbem_cp_locations_has_archive’, false) == true,and put in after that line…
‘show_in_rest’ => true,And it should work..
You call up the JSON.. with a link like this…
yourwebsite.com/wordpress/wp-json/wp/v2/eventYou can paste your JSON file into a website like this to see it better…
http://jsonlint.com/ or one of the many others available..
CAUTION !!!!
I am doing all this on my Local Development Machine using WP 4.4xALWAYS BACK UP YOUR FILES AND DATABASES.. and know how to FTP to your website
Pretty cool stuff and hope you have success !
I’ve been up since 2am.. and I am going to have a cheap American beer !Slight error in above post…
Search for the lines that begin with
Search for the lines
that have…
‘has_archive’and put in after that line…
‘show_in_rest’ => true,The previous notation was to specific and you will miss some of the
‘has_archive’ lines..I think there were three of them.
hi robswaimea,
I have no words to explain how you are kind for all these answer: really, really, really thanks 🙂I did all you explain:
1) install plugin https://wordpress.org/plugins/rest-api/ and add lines
‘show_in_rest’ => true in em-posts.php..this retrive me a JSON “https://www.MYSITE.it/wp-json/wp/v2/posts” but “https://www.MYSITE.it/wp-json/wp/v2/event” not.
I have this message: {“code”:”rest_no_route”,”message”:”Nessun percorso fornisce una corrispondenza tra l’URL e le modalità di richiesta”,”data”:{“status”:404}}
There’s no correspondence between url and modality request.What could be the problem? thank you again 🙂
{"code":"rest_no_route","message":"Nessun percorso fornisce una corrispondenza tra l'URL e le modalità di richiesta","data":{"status":404}}You need to check if “Events” is even being produced..
You said “posts” works ? Yes..
What you need to do is “see” if “Events” is actually created…
Try..
mywordpresswebsite/wp-json/wp/v2/typesWhen you get the JSON.. I like to put it in a viewer like..
http://jsonlint.com/Just makes it easier to read…
That should output all the available JSONS
ie Posts.. Pages…Attachment,And thus you should also see…
The same for Events, Locations, Event-recurring…
just like Post, Pages, Attachments….
Looks something like this…"event": { "description": "Display events on your blog.", "hierarchical": false, "name": "Events", "slug": "event", etc, etc, etc, etc....I am new to Output JSON… my experience is from “pulling” JSON.
Hope you get it worked out..
But if you get something for Posts.. then it should work for Events.
OMG It works, really really thanks 🙂
This code works for me:
http://www.dayroma.it/wp-json/wp/v2/event
Now that we are JSON Friend, I’d like to ask you: can you help to add new routes to REST API?
I tried to follow the guide, but it doesn’t work this:
function my_awesome_func( $data ) { $posts = get_posts( array( 'author' => $data['id'], ) ); if ( empty( $posts ) ) { return null; } return $posts[0]->post_title; } <?php add_action( 'rest_api_init', function () { register_rest_route( 'wp-json/wp/v2/', '/author/(?P<id>\d+)', array( 'methods' => 'GET', 'callback' => 'my_awesome_func', ) ); } );I put this code to functions.php in my child theme, Is it wrong?
I would like to get events filtered by date (today, tomorrow, or other), can you help me to understand the way?
YOU ARE SO KIND 🙂
Now that we are JSON FriendYou haven’t even bought me a beer yet !
Just kidding…
Glad you got it worked out !I looked at your main site.. and it is beautiful !
We are both doing entertainment, music, festivals.. that’s cool !My brain is all mushy right now.. and all scrambled as I was working hard on some other JSON and XML stuff..
I can hardly see straight 🙂As to your direct question.. I really can’t make any knowledge of it…
It looks like it pertains more to the the Rest Api Plugin..I am not very familiar with WordPress and Output API (JSON)…
So pulling it back in… and making it work I don’t know.Everything I do is pulling in API JSON, converting it to XML…
And thusly… my inexperience with your project.I tried to follow the guide, but it doesn't work this:.......BUT…
I’d look at how you write these lines…
'author' => $data['id'],
and..
return $posts[0]->post_title;those appear to be your “filters”… I would try and research info on that.
I am not sure this will help… but looking at the “structure” of you API JSON might give you a clue…
So take your your http://www.dayroma.it/wp-json/wp/v2/event
and paste it into
http://codebeautify.org/jsonviewer
In the middle of the page use the button “JSON to XML”
to convert it to XML….Maybe this will give you ideas with…
function my_awesome_func( $data ) { $posts = get_posts( array( 'author' => $data['id'],And if you do resolve the issue it would be wonderful if you shared your knowledge.
Have a great a weekend !
If you are saying the code you put in above…
“Broke” your website…Take out the line…
<?phpHonestly… at this point.. I think you are going to get some other help.
While I did some reading.. and it looks like you may have to “add” custom filters…
I don’t know anymore on this project.Good luck hope you get it worked out !
Very kind as usual, how can I buy you a beer? 🙂
I really thank you for your time spent for me.
As soon as I can fix my code problem, I’ll be happy to write you, either here or directly by email if you want, you are very nice, see you 😉
The topic ‘Get JSON Events List’ is closed to new replies.