I am studying and implementing an api and while following the examples,
Here is the example 1 :
curl -X POST \
-H "Content-Type: application/json" \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-d '{"application_id": "2", "auth_key": "DtF9cZPqTF8Wy9Q", "timestamp": "1333630580", "nonce": "1340569516", "signature": "13293a5bd2026b957ebbb36c89d9649aae9e5503", "user": {"login": "injoit", "password": "injoit"}}' \
https://api.quickblox.com/session.json
For the above example i consructed my get method as
https://api.quickblox.com/session.json?token=re8d22c6e617133ffeadd761193a6c57d87bfb1a0f&application_id=23995&auth_key=CbRasu4Wftu25Qw&nonce=8796×tamp=1434446627&signature=667ee2b448a5d3dd57d112afef3f84dd6c67e165
and it is working good.
But for the below example
curl -X POST \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 17f6a337b0656c9c7e983f9705d79562fc694c0e" \
-H "Content-Type: application/json" \
-d '{"push_token": {"environment": "production", "client_identification_sequence": "aa557232bc237245ba67686484efab"},
"device": {" platform": "iOS", "udid": "5f5930e927660e6e7d8ff0548b3c404a4d16c04f"}}' \
http://api.quickblox.com/push_tokens.json
How can i create the get method. As this has two main arrays i am little confused.
Can anyone help in creating how can i use this call ?
It should be something like this:
https://api.quickblox.com/push_tokens.json?push_token[environment]=production&push_token[client_identification_sequence]=aa557232bc237245ba67686484efab&device[platform]=iOS&device[udid]=5f5930e927660e6e7d8ff0548b3c404a4d16c04f
Related
I need help because in my team we are using an old version of php and its impossible to use any bundle.
I'm trying to make the request with curl but Im having a lot of problems with authentication.
Could anyone tell me how to make a simple curl request to send a tweet using the twitter api?
Thanks a lot!!
curl -X POST 'https://api.twitter.com/2/tweets/search/stream/rules' \
-H "Content-type: application/json" \
-H "Authorization: Bearer $APP_ACCESS_TOKEN" -d \
'{
"add": [
{"value": "cat has:images", "tag": "cats with images"}
]
}'
it's just an example - but it's nicely described in the documentation
I'm using PHP shell_exec to call the Bluemix Text to Speech API and my code is working well except when I call the text with SSML tags like my second code.
How could I use text and SSML in the same data query?
$result = shell_exec("/usr/bin/curl -k -u 'XXX':'XXX' -X POST \
--header 'Content-Type: application/json' \
--header 'Accept: audio/wav' \
--max-time 90000 \
--output 'public/uploads/audios/padrao_bomdia.wav' \
--data '{\"text\":\"Hello! This is an test.\", \"voice\":\"pt-BR_IsabelaVoice\"}' \
'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=pt-BR_IsabelaVoice'");
$result = shell_exec("/usr/bin/curl -k -u 'XXX':'XXX' -X POST \
--header 'Content-Type: application/json' \
--header 'Accept: audio/wav' \
--max-time 90000 \
--output 'public/uploads/audios/padrao_bomdia.wav' \
--data '{\"text\":\"Hello! <say-as interpret-as="letters">Hello</say-as> This is an test.\", \"voice\":\"pt-BR_IsabelaVoice\"}' \
'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=pt-BR_IsabelaVoice'");
Does say-as interpret-as="letters" Hello fragment need the escape slashes around 'letters'?
Unfortunately, Only US-English Allison voice supports Expressive SSML. Isabela, the PT-BR voice, does not support SSML. That's why it's not working.
Reference:
Currently, the service supports expressiveness only for the US English
Allison voice (en-US_AllisonVoice). Using the element with any other
voice returns an error.
I wondering if is good (or bad), to use exec() command in PHP ...
For example, with API Paypal REST, I use exec() (with curl) rather than the curl from PHP
$a = exec('curl -v '.$this->ENDPOINT.'/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: fr_FR" \
-u "'.$this->CLIENTID.':'.$this->SECRET.'" \
-d "grant_type=client_credentials"'
);
$a = json_decode($a);
What is the impact? Is it better not to do?
Thanks guys
If those parameters are not coming from an end-user then you are pretty-safe. If not, then you should definitely filter them through escapeshellarg()
The secure code..
$a = exec('curl -v '.escapeshellarg($this->ENDPOINT).'/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: fr_FR" \
-u "'.escapeshellarg($this->CLIENTID).':'.escapeshellarg($this->SECRET).'" \
-d "grant_type=client_credentials"'
);
$a = json_decode($a);
I am having a problem with my php script.
When i run this command in terminal :-
curl -X POST -H "X-Futuresimple-Token:mytoken" \
-H "Accept:application/xml" \
-H "Content-Type:application/json" \
--data "{\"lead\" : { \"company_name\" : \"Cody Test\", \
\"first_name\" : \"Cody\", \"last_name\" : \"Guest\", \"email\" : \"Cody.guest#boxview.com\" }}" \
https://leads.futuresimple.com/api/v1/leads.json
It works. But i want to convert it into PHP so that i can get the response using PHP
Thanks
Slap on the "--libcurl example.c" option to get your program in plain C, from there it is usually easy to make it into PHP...
I have the following:
curl -X POST \
-H "X-Parse-Application-Id: appid"
-H "X-Parse-REST-API-Key: restkey"
-H "Content-Type: text/plain"
-d 'Hello, World!'
https://api.parse.com/1/files/hello.txt
And I get back:
{"url":"http://files.parse.com/7680c0e7-b398-4b43-91f0-61b12934c690/08d828ef-1185-4036-b8ab-228764fbeb69-hello.txt","name":"08d828ef-1185-4036-b8ab-228764fbeb69-hello.txt"}
What's the file name I should use?
the URL returned - you take everything after http://files.parse.com/
That comes to the following:
curl -X POST \
-H "X-Parse-Application-Id: appid" \
-H "X-Parse-REST-API-Key: reskey" \
-H "Content-Type: application/json" \
-d '{
"name": "blisdco",
"picture": {
"name": "7680c0e7-b398-4b43-91f0-61b12934c690/08d828ef-1185-4036-b8ab-228764fbeb69-hello.txt",
"__type": "File"
}
}' \
https://api.parse.com/1/classes/CustomerImages
And what is returned is:
{"createdAt":"2012-06-12T20:16:05.360Z","objectId":"yHLhqMgBAj"}
If you look at CustomerImages table in the Parse Data Browser, you'll see the entry - including the file name portion of the URL.