Use a REST API: Difference between revisions
m
→{{header|Wren}}: Minor tidy
(Added Wren) |
m (→{{header|Wren}}: Minor tidy) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 24:
<br>
Note that this version doesn't include code to submit events to Meetup.
<
import (
Line 147:
fmt.Println("First event:\n", &evresp.Results[0])
}
}</
{{out}}
<pre>
Line 163:
<br>
Note that this code is untested as you need a paid subscription to create events which I don't have.
<
import (
Line 260:
check(err)
fmt.Printf("The %q event has been cancelled.\n", event.Name)
}</
=={{header|Java}}==
Line 268:
EventGetter.java
<
import java.io.BufferedReader;
Line 326:
}
}</
Main.java
<
* In this class, You can see the diferent
* ways of asking for events.
Line 418:
}
}</
=={{header|JavaScript}}==
Line 424:
Made on node js. Run using 'node filename.js'
<
var request = require('request');
Line 567:
}, function(result) {
console.log('Event: ', result);
})</
=={{header|Phix}}==
Line 573:
Unfortunately the API (V2) does not support creating events, so instead this shows how to use
a post method to toggle sales (but see note below).
<!--<
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\Using_a_REST_API.exw
Line 681:
<span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">toggle_sales</span><span style="color: #0000FF;">({</span><span style="color: #008000;">"eventid"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">id</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"status"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">status</span><span style="color: #0000FF;">},</span><span style="color: #008000;">"events/togglesales"</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">print_json</span><span style="color: #0000FF;">(</span><span style="color: #008000;">""</span><span style="color: #0000FF;">,</span><span style="color: #000000;">res</span><span style="color: #0000FF;">))</span>
<!--</
Note that toggling sales off makes the (manually created) event invisible to the API, even without
the {"status","live"} filter, hence I had to hard-code the event id to permit a second run to turn
Line 746:
eventGetter.py
<
import requests
import json
Line 772:
def submitEvent(url_path,params):
r = requests.post(url_path, data=json.dumps(params))
print(r.text+" : Event Submitted")</
main.py
<
import json
Line 890:
main()</
=={{header|Wren}}==
Line 900:
I did wonder whether it was worth the effort to do this task given that we're using a deprecated API and can't test creating events without a paid subscription which I don't have. However, from Wren's viewpoint, there are some points of interest relating to the use of WrenGo - notably passing Wren maps to Go - which may be a useful reference for the future.
<
import "./date" for Date
Line 991:
// delete the event just posted
c.deleteEvent(event.eventId)
System.print("The %(event.eventName) event has been cancelled.\n")</
<br>
We now embed this in the following Go program and build it. To run it, you will need the necessary authorization, a paid subscription and, of course, non-fictitious data.
<
package main
Line 1,237:
module := wren.NewModule(classMap)
fileName := "
vm.SetModule(fileName, module)
vm.InterpretFile(fileName)
vm.Free()
}</
{{omit from|EasyLang}}
|