I need to use mailgun api in objective-c Mac OS X. I did try different solution without success. A possible solution I think is to convert the cUrl call with NSURL. so any help for achieve this is largely valued. thanks for your time
curl -s --user 'api:key-0000000000000000000' \
https://api.mailgun.net/v3/sandbox000000000000000.mailgun.org/messages \
-F from='Excited User <mailgun#sandbox000000000000000.mailgun.org>' \
-F to=me#gmail.com \
-F to=bar#example.com \
-F subject='Hello' \
-F text='Testing some Mailgun awesomness!'
Related
I have lots of nagios services with forward slash in their names. When I try to acknowledge the service through thruk api, it returns error like below.
request: http://<thruk_url>/r/v1/services/test-host/check_disk_%2Fvar/cmd/acknowledge_svc_problem
response: /r/v1/services/test-host/check_disk_/var/cmd/acknowledge_svc_problem was not found on this server.
The service name is check_disk_/var. I have lots of services like these, thus renaming all of them is not an easy solution.
There is a generic command endpoint as described here:
https://thruk.org/documentation/rest_commands.html#_generic-command-endpoint
%> curl -H "X-Thruk-Auth-Key: ****" \
-d "cmd=acknowledge_svc_problem" \
-d "host=hostname" \
-d "service=servicedescription" \
-d "comment_data=test" \
'http://localhost/thruk/r/cmd'
For a very long time I've been using the following to send text-to-speech alerts from my applications.
curl 'https://api-us-1.nexmo.com/tts/json' \
-d api_key=****** \
-d api_secret=****** \
-d to=0035193xxxxxxx \
-d from=0035193xxxxxxx \
--data-urlencode 'text=Alert! Check Something... ' \
-d repeat=2 \
-d voice="male" \
Very recently the service has stopped working for some carriers.
While going over Nexmo docs I can't see the /tts/json API documented.
Anyone knows what happened?
Is the /tts/json API still usable?
The /v1/calls API is absolutelly overkill for my needs.
Unfortunately that API was sunset quite a while ago and replaced with the newer Voice API.
https://developer.nexmo.com/voice/voice-api/code-snippets/make-an-outbound-call-with-ncco would the closest alternative with the Voice API. The biggest change is switching to using a JWT for authentication versus the key/secret auth the older API used.
If you have the Nexmo CLI installed you can generate a JWT as part of a script. The following should work:
#!/bin/bash
#
# Send voice message to a user
#
# ./script.sh <number to call> <vonage number> "<message to speak>"
PATH_TO_PRIVATE_KEY=<path to private key>
VONAGE_APPLICATION_ID=<application ID>
TO_NUMBER=$1
VONAGE_NUMBER=$2
MESSAGE=$3
JWT=$(nexmo jwt:generate $PATH_TO_PRIVATE_KEY application_id=$VONAGE_APPLICATION_ID)
curl -X POST https://api.nexmo.com/v1/calls\
-H "Authorization: Bearer "$JWT\
-H "Content-Type: application/json"\
-d "{\"to\":[{\"type\": \"phone\",\"number\": \"$TO_NUMBER\"}],
\"from\": {\"type\": \"phone\",\"number\": \"$VONAGE_NUMBER\"},
\"ncco\": [
{
\"action\": \"talk\",
\"text\": \"$MESSAGE\"
}
]}"
I have been working with curl request (from bash)
/usr/bin/curl -L -k -u admin:admin -X GET 'https://localhost/test/123/123'
How can I translate this request to the pycurl code, and implement it through python, options are important as it is REST API.
The options that I used in curl are
-k for insecure(ssl bypass)
-L redirect
-X request GET
Thanks,
There is documentation that you can read for information. It references CURL's setopt options. If you read the documentation you'd figure out what you want to know, but I assume you're asking here because you want someone else to read it for you.
import pycurl
c = pycurl.Curl()
c.setopt(c.URL, "https://localhost/test/123/123")
c.setopt(c.SSL_VERIFYPEER, False) # -k
c.setopt(c.FOLLOWLOCATION, True) # -L
c.setopt(c.HTTPGET, True) # -X
c.perform()
I do know rabbitmq_tracing, which is a plugin of RabbitMQ, can provides a GUI to capture traced messages and log them in text or JSON format files. But the plugin is performance costing, is there a way to log all messages without this plugin?
Or is there a eclectic way to log messages automatically without using the management plugin? Because configuring traces on the GUI is not tolerant for some customers.
Any response would be appreciated.
I can't find a good solution to log all messages without rabbitmq_management. But with this plugin turned on, add and delete rabbitmq trace via command line:
Add a new trace:
[windows:] curl -i -u guest:guest -H "content-type:application/json" -XPUT ^ http://localhost:15672/api/traces/%2f/my-trace ^ -d"{""format"":""json"",""pattern"":""#"",""max_payload_bytes"":1000}"
[linux:] curl -i -u guest:guest -H "content-type:application/json" -XPUT \ http://localhost:15672/api/traces/%2f/my-trace \ -d'{"format":"text","pattern":"#", "max_payload_bytes":1000}'
Delete a trace:
[windows:] curl -i -u guest:guest -H "content-type:application/json" -XDELETE ^ http://localhost:15672/api/traces/%2f/my-trace
[linux:] curl -i -u guest:guest -H "content-type:application/json" -XDELETE \ http://localhost:15672/api/traces/%2f/my-trace
I am trying to follow the reddit api, as outlined here:
https://github.com/reddit/reddit/wiki/API
Logging in using curl is not a problem:
curl -d user=user -d passwd=pass -c Cookie.txt http://www.reddit.com/api/login
Which gives me a cookie, in which (I assume) contains my user mod-hash:
4029916%2C2010-04-30T22%3A51%3A52%2C1243925043100000000000000000000000000000
Next I am trying to post, using:
curl -d uh=4029916%2C2010-04-30T22%3A51%3A52%2C1243925043100000000000000000000000000000 -d sr=test -d title=test -d r=test -c Cookie.txt http://www.reddit.com/api/submit
However, I receiver an error:
[".error.USER_REQUIRED"]
Can someone explain what I have done incorrectly/how I can fix it?
Look here: https://github.com/reddit/reddit/wiki/API%3A-login
Notice that cookie isn't the same thing as modhash.