Apply a function into all my active numbers - function

We created a function and now We want to apply this to all our active numbers but I couldn't find a way to change this in mass yet.
Is this posible ?

There are multiple options:
You can create a messaging service, configure the webhook there, and then add all your senders to it.
You could use the API or Twilio CLI to write a script that fetches all active numbers and assigns the Function URL to them.
curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers/PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json \
--data-urlencode "VoiceUrl=http://functionURL.com/twilio" \
--data-urlencode "BundleSid=BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
You can use TwiML Apps for this.

Related

Get JSON data from Parse.com database using HTTP request

I am new to Parse.com and have some data stored in my database class (musical_data).
Is it possible to send a get request in my browser and have it return JSON to me? I have tried to retrieve the data, but can't figure out how to display the database class data in JSON via my browser.
Thanks
Example, this CURL form works.. But I want to type it into the browser url bar.
curl -X GET \
-H "X-Parse-Application-Id: wfwefwefwef" \
-H "X-Parse-REST-API-Key: wefwefwe123" \
https://api.parse.com/1/classes/musical_data
This format should work in the browser:
https://APPID:javascript-key=JSKEY#api.parse.com/1/classes/musical_data
Replace APPID with your application id and replace JSKEY with your JavaScript key

trying to retrieve one object based on conditions values using Android REST API

I’m using Parse.com, and trying to retrieve one object based on conditions values using Android REST API
here is a snippet from the Parse documentation for the REST API
curl -X GET \
-H "X-Parse-Application-Id: MYAPPID" \
-H "X-Parse-REST-API-Key: MYRESTKEY" \
-G \
--data-urlencode 'where={"$relatedTo":{"object":{"__type":"Pointer","className":"Post","objectId":"8TOXdXf3tz"},"key":"likes"}}' \
https://api.parse.com/1/users
How can I achieve this in android?
It's curl based api, you have to explicitly pass all its parameter.
I recommending you to first test api using client application like Postman.
-X define term like GET,POST,PUT,DELETE
-H define header, which has key-value form data separated by ":" sign.
-G When used, all data to be used in an HTTP GET request instead of the POST request that otherwise would be used. The data will be appended to the URL with a '?' separator.
Pass all these parameters and test it, once it is working fine then implement to your application.

nodebb write api example to create new user

Looking for an example of how to create a new user using the write API defined here: https://github.com/NodeBB/nodebb-plugin-write-api?files=1
Have tried:
curl -H "Authorization: Bearer MASTER-TOKEN-HERE" --data "username=fredy&password=SomePassword123&email=fred#fredy.com&_uid=SOME-OTHER-TOKEN" http://localhost:4567/api/v1/users
I get unauthorized error. The MASTER TOKEN was generated using the Write API plugin. So was the SOME-OTHER-TOKEN (a user/token, generated when i clicked "create token button")
Any clues?
Figured it out. The _uid is not a token. Its the user id. (obviously..) I just used _uid=1 (which was my admin id) and all worked fine!

Sending SMS using the Pushbullet API via Bash scripting (curl)

I'm working on a cli for the Pushbullet HTTP API using Bash scripting. Sending pushes (notes and links), as well as creating, deleting, and modifying contacts & devices are all straight forward using curl and Bash. However, sending SMS and files are a bit more complex, as both require sending more complex JSON-formatted requests to the server (multiple JSON-formatted requests, in the case of pushing files).
I've tried sending many variations on the following (both with and without escape characters), but the server keeps replying about JSON-formatting errors. The following code is based off of the example given in the Pushbullet HTTP API documentation.
curl -su $auth_id: -X POST https://api.pushbullet.com/v2/ephemerals --header "Content-Type: application/json"
--data-binary '{ "\"type"\": "\"push"\", "\"push"\": { \
"\"type"\": "\"messaging_extension_reply"\", \
"\"package_name"\": "\"com.pushbullet.android"\", \
"\"source_user_iden"\": "\"$source_idens"\", \
"\"target_device_iden"\": "\"$target_idens"\", \
"\"conversation_iden"\": "\"$sms_device"\", \
"\"message"\": "\"Hello"\" \
} }'
Using bash -x, I can see that this is (supposedly) what is being sent to the server:
--data-binary '{"type": "push", "push": {
"type": "messaging_extension_reply",
"package_name": "com.pushbullet.android",
"source_user_iden": "<source_idens>",
"target_device_iden": "<device_idens>",
"conversation_iden": "<sms_phone_number>",
"message": "Hello" } }'
In all cases, the server returns:
{"error":{"type":"invalid_request","message":"Failed to parse JSON body.","cat":"(=^‥^=)"}}
What is the appropriate formatting of a JSON request using curl to send an SMS via the Pushbullet API? Am I overlooking something obvious? I'm trying to accomplish this using only curl and Bash, I see no reason why it's not possible (maybe not the fastest or most elegant way, but certainly possible).
I found the solution to my issue so I thought I'd share it. It was actually very simple:
Because the curl command includes a JSON-formatted response with single quotes, variable expansion was not occurring. This is a limitation (or perhaps a feature) of Bash. So, even though the server responded with { } indicating no errors in the request, the requests were actually being sent without the proper values for parameters, such asuser_iden,source_user_iden, etc.
Solution:
Enclose all variable expansions inside the JSON-formatted request in a double-quote and single-quote, like so:
"'"$user_idens"'"
First I'd like to apologize for how bad the API is, especially file upload and sending SMS. I was thinking of adding multipart or base64 file uploads to /v2/pushes. I think the first one might help you with curl, not sure about the base64 one. multipart is a huge pain though, so I'd prefer to make it better than the current setup if possible, rather than about equally as bad. Suggestions are welcome.
I tried your command line and it seemed to work, so I'm not sure what is going wrong. Here's the command line I did. Perhaps your quote escaping or newlines are causing the JSON error?
curl -u <access_token> -X POST https://api.pushbullet.com/v2/ephemerals --header "Content-Type: application/json" --data-binary '{"type": "push", "push": {"type": "messaging_extension_reply","package_name": "com.pushbullet.android","source_user_iden": "iden","target_device_iden": "device_idens", "conversation_iden": "sms_phone_number","message": "Hello" } }'

Jenkins remote API - trigger job with static pulldown paramters

I am attempting to trigger a Jenkins build remotely via curl that has required parameters. These parameters are in the form of a static pull down.
I am able to trigger the build remotely via curl, but the parameters are not being passed - it appears that it is just taking the first (default) from each pull down.
Here is the curl command:
export json="{\"parameter\": [{\"name\": \"ENV\", \"value\": \"dev-1\"},{\"name\": \"PLATFORM\", \"value\": \"desktop\"},{\"name\": \"PRODUCT\", \"value\": \"Test\"}]}"
curl -H ".crumb:xxxxxxxxxxxxxxxxxxxxxx" -X POST http://server:8080/job/job_name/buildWithParameters -d token=tokenId --data-urlencode json="$json"
From what I can tell the JSON is valid - is there a different set of elements required for a static pull down list?
Thanks!
Use http://server:8080/job/job_name/build instead of buildWithParameters, as shown in the example for using the remote access api.
I'm not sure what's the reason for the difference, and it was a bit confusing for me at first, but when using buildWithParameters you need to add the parameters to the url as you found out with your wget command - and at the same time you can also add parameters when using the normal build trigger.
Note that when you trigger a build this way, it will still work if you leave out some parameters, but for those the default value won't be used (they will be unspecified).
I got this to work using wget instead of curl, but I'd still be interested in knowing how to make this work with curl if anyone has pointers.
This command works:
wget --delete-after --auth-no-challenge --http-user=${userID} --http-password=${authToken} http://server:8080/job/job_name/buildWithParameters?token=runme\&ENV='dev-1'\&PLATFORM='desktop'\&PRODUCT='Test'