I'm trying to send a message to my phone with curl:
curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/<my-trial-sid>/Messages.json' \
--data-urlencode 'To=+<my-phone-number>' \
--data-urlencode 'From=+15005550006' \
--data-urlencode 'Body=Hello from twilio' \
-u <my-trial-sid>:<my-trial-token>
However I never get the message on the phone. The response show status as 'queued'. What's keeping it from being sent?
The complete response I get:
{"sid": "SM18ce5f04a0ed4d6e8bfdc91d862d7b7f", "date_created": "Wed, 08 Mar 2017 01:59:07 +0000", "date_updated": "Wed, 08 Mar 2017 01:59:07 +0000", "date_sent": null, "account_sid": "<my-trial-sid>", "to": "+<my-phone-number>", "from": "+15005550006", "messaging_service_sid": null, "body": "Sent from your Twilio trial account - Hello from twilio", "status": "queued", "num_segments": "1", "num_media": "0", "direction": "outbound-api", "api_version": "2010-04-01", "price": null, "price_unit": "USD", "error_code": null, "error_message": null, "uri": "/2010-04-01/Accounts/<my-trial-sid>/Messages/SM18ce5f04a0ed4d6e8bfdc91d862d7b7f.json", "subresource_uris": {"media": "/2010-04-01/Accounts/<my-trial-sid>/Messages/SM18ce5f04a0ed4d6e8bfdc91d862d7b7f/Media.json"}}%
Can't find any relevant log entries on the console either. What am I missing?
Twilio developer evangelist here.
It looks like you are using your test credentials here. Test credentials will never actually send an SMS, they just allow you to make sure you are making the API request correctly.
You should do make the same API call but with your regular credentials and messages will be sent. If you are still on a trial account then this message will not cost you anything.
Related
I am trying to create new responses using SurveyMonkey API, I am following this document provided by SurveyMonkey: https://developer.surveymonkey.com/api/v3/?shell#collectors-id-responses
and here is the request I am making:
curl -i -X POST -H "Content-Type: application/json" -H "Authorization:bearer ACCESS_TOKEN" https://api.surveymonkey.com/v3/surveys/{suvey_id}/responses -d '{"custom_variables":{"custvar_1": "one", "custvar_2": "two"},"response_status": "completed","custom_value": "custom identifier for the response","date_created": "2015-10-06T12:56:55+00:00","ip_address": "127.0.0.1", "pages": [{"id": "{page_id}","questions": [{"answers": [{"text": "Sample Text Response"}], "id": "{questions_id}"}, {"answers": [{"choice_id": "{choice_id}"}], "id": "{questions_id}"}]}]}'
and I am getting a 404 response:
{"error": {"docs": "https://developer.surveymonkey.com/api/v3/#error-codes", "message": "There was an error retrieving the requested resource.", "id": "1020", "name": "Resource Not Found", "http_status_code": 404}}
I have verified values of "choice_id", "questions_id", "page_id" and "survey_id", all of them are correct but I am still getting a 404, I am completely stuck down with this issue, any help in this regard will be highly appreciated.
Thanks!
According to the docs, when Twilio receives a message from a Twilio numbers it makes a synchronous HTTP request to the message URL configured for that number. Twilio sends the the parameters listed at https://www.twilio.com/docs/api/twiml/sms/twilio_request
Is it possible to have the date/time sent and/or received passed to the configured URL as well, and if so, how?
Dates and Times are addressed as such and are attached to the messages resource.
{
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"api_version": "2010-04-01",
"body": "Hey test message",
"error_code": null,
"error_message": null,
"num_segments": "1",
"num_media": "0",
"date_created": "Mon, 16 Aug 2010 03:45:01 +0000",
"date_sent": "Mon, 16 Aug 2010 03:45:03 +0000",
"date_updated": "Mon, 16 Aug 2010 03:45:03 +0000",
"direction": "outbound-api",
"from": "+14158141829",
"price": "-0.02000",
"sid": "MMXXXXXXXXXXXXXXXXXXXXXXXXX",
"status": "sent",
"to": "+15558675309",
"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MMXXXXXXXXXXXXXXXXXXXXXXXXXXXec.json"
}
I am trying to make a GeoJSON query work as per the Eve documentation (v0.6.1-dev): http://python-eve.org/features.html
However, the query in postman returns an error:
Postman GET: http://localhost:5000/people?where={"location": {"$near": {"$geometry": {"type":"Point", "coordinates": [10.0, 20.0]}, "$maxDistance": 1000}}}
Error:
500 Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
The 'people' collection contains the location as show below:
Postman GET: http://localhost:5000/people
"_items": [
{
"_updated": "Wed, 30 Sep 2015 10:26:51 GMT",
"firstname": "John",
"lastname": "Doe",
"born": "Thu, 27 Aug 1970 14:37:13 GMT",
"role": [
"author"
],
**"location": {
"type": "Point",
"coordinates": [
100,
0
]
},**
"_links": {
"self": {
"href": "people/560bb8eb6adf7d0e70f26cd0",
"title": "person"
}
},
Any idea why this does not work ?
Try to switch on debug mode (set DEBUG = True in settings) and see what the actual error is. It is very likely that there is no geo index for the field (Eve does not automatically create indexes for you).
UPDATE: Starting with v0.6, you can also ask Eve to maintain the index for you, see the mongo_indexes keyword in the docs
I'm using the following Python code to send Mandrill email:
json_mandrill = dict(
key=MANDRILL_KEY,
template_name=template_name,
template_content=[],
global_merge_vars=[],
message=dict(to=[dict(email=recipient)])
)
for name, content in merge_vars.items():
json_mandrill["global_merge_vars"].append(
dict(name=name, content=content))
url = "https://mandrillapp.com/api/1.0/messages/send-template.json"
logging.info(json.dumps(json_mandrill))
result = urlfetch.fetch(url=url,
payload=json.dumps(json_mandrill),
method=urlfetch.POST,
headers={'Content-Type': 'application/x-www-form-urlencoded'})
Here is an example of the submitted JSON from my logs:
{"global_merge_vars": [{"content": 7, "name": "free_duration"}, {"content": 4615291308867584, "name": "eid"}, {"content": "poll", "name": "mode"}, {"content": "31 July 2015 at 09:44 EDT", "name": "exp"}, {"content": "Jeff", "name": "name"}],
"template_content": [],
"message": {"to": [{"email": REDACTED}]},
"key": REDACTED,
"template_name": "manager-welcome"}
My Mandrill settings are set to use Handlebars and here is an excerpt from the template:
<p>Dear {{name}},</p>
And this is what appears in the received email:
<p>Dear ,</p>
The emails get sent, but the merge variables in the email are just blank. Any idea what I am doing wrong?
Looking at the submitted JSON, it looks like the "global_merge_vars" aren't nested properly. They should be nested in the "message" struct, instead of on the same level.
I'm trying to find a way to just get tweets to all users. The JSON code indicates these as "to_user" null. For example the tweet below edent tweets to everyone, thus the to_user=null.
I tried a few alternatives without success:
http://search.twitter.com/search.json?q=to:null%20from:edent&result_type=mixed
http://search.twitter.com/search.json?q=to:0%20from:edent&result_type=mixed
http://search.twitter.com/search.json?q=to:%20from:edent&result_type=mixed
{
"created_at": "Thu, 28 Jun 2012 06:55:58 +0000",
"from_user": "edent",
"from_user_id": 14054507,
"from_user_id_str": "14054507",
"from_user_name": "Terence Eden",
"geo": null,
"id": 218236278402068480,
"id_str": "218236278402068480",
"iso_language_code": "en",
"metadata": {
"result_type": "recent"
},
"profile_image_url": "http://a0.twimg.com/profile_images/2318692719/7182974111_ec8e1fb46f_s_normal.jpg",
"profile_image_url_https": "https://si0.twimg.com/profile_images/2318692719/7182974111_ec8e1fb46f_s_normal.jpg",
"source": "<a href="http://twitter.com/">web</a>",
"text": "RT #straczynski: #edent Clearly the man was ahead of his time.",
"to_user": null,
"to_user_id": 0,
"to_user_id_str": "0",
"to_user_name": null,
"in_reply_to_status_id": 218075066452287500,
"in_reply_to_status_id_str": "218075066452287488"
},
If you're just looking to get tweets from a particular user that aren't to anyone, use the /get/statuses/user_timeline REST API endpoint instead of the Search API. /get/statuses/user_timeline has an exclude_replies parameter that should do what you're looking for.
The Search API doesn't have any way to exclude replies. Your only option is to get tweets matching whatever other parameters you pass, and process them on your end to remove any whose text starts with "#".