Search for file using Box.com Android SDK - search

Using the sdk, how do I search a file and get information about it? The only option I see is to go through all files and folders which is inconvenient and takes a lot of code.
Is there an easier way? If not with the SDK, a REST option perhaps?
Thanks

I found this from http://developers.box.com/docs/#search
curl https://api.box.com/2.0/search?query=football&limit=1&offset=0 \
-H "Authorization: Bearer ACCESS_TOKEN"
I can search for any object and it returns a json response with the results.
I still don't know how to do it with the SDK but REST did the same job.

Android sdk provides such an option.
You can do this:
boxClient.getSearchManager().search(searchQuery, null);
this method will return you a BoxCollection, every item in the collection should match your search query.

Related

Get list of files name and path in whole google cloud with a particular file extension using NodeJS

I have a google cloud bucket which is having the files with the extension .jtl, I need to get these file names and paths irrespective of the nesting of folders they are in using NodeJS.
How can we do that!
I think this link might help you
https://cloud.devsite.corp.google.com/storage/docs/json_api/v1/objects/list
You can try this API, and give the preferred parameters present in that,
for example: in your case you can give delimiter as jtl, and then you can copy the curl command or http or node JS as you prefer and execute this in your google cloud platform
The command will look something like this:
curl
'https://storage.googleapis.com/storage/v1/b/xyz12345/o?delimiter=jpg&includeTrailingDelimiter=true&key=[YOUR_API_KEY]'
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]'
--header 'Accept: application/json'
--compressed
Provide your API key and Access token to be able to run this in your google cloud platform.

Activating Google Speech API in Firebase CLI?

I get this error when I try to use Google Speech from either the cmd command line (Windows 10) using curl or from a local Firebase server.
"Cloud Speech API has not been used in project firebase-cli before or
it is disabled. Enable it by visiting
https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=firebase-cli
then retry"
Going to the suggested URL just gives the message:
The API "speech.googleapis.com" doesn't exist or you don't have permission to access it
The curl command has worked before. Login seems to work (using Bearer header). I have no idea why it does not work now. Did I do something before that made it work? Or is there some change to Firebase CLI/Google Speech?
EDIT: Here is the curl command that worked before. I do not think it matters here, but someone might be interested still:
#for /f %%i in ('gcloud auth application-default print-access-token') do #set bearer=%%i
curl -X POST ^
-H "Authorization: Bearer %bearer%" ^
-H "Content-Type: application/json; charset=utf-8" ^
--data #request-flac.json ^
"https://speech.googleapis.com/v1/speech:longrunningrecognize"
Follow the Cloud Speech API quickstart. There is a button that will help you enable the API in your project. If you don't want to do it that way:
Go to the GCP console
Select the APIs and Services option in the left menu
Select dashboard
Click Enable APIs and Services
Type "speech" in the search box
Click the "Speech API" card
Click Enable
This is the generalized way to enable APIs in your project.

Deleting a feed using REST API

My requirement is to clear all activities on a notification feed.
Based on this stackoverflow question I understand that there is an undocumented REST API to delete a feed and the dashboard truncate feed functionality uses it.
I tried to replicate the call with the same parameters as dashboard:
DELETE /api/v1.0/feed/notification/f8fa1d12-594a-4b2b-ac58-23c912d1335a/?api_key=...&location=unspecified
Host: api.getstream.io
Authorization: notificationf8fa1d12-xxxx-xxxx-xxxx-23c912d1335a writetoken
stream-auth-type: simple
X-Stream-Client: stream-javascript-client-browser-unknown
Cache-Control: no-cache
Tried to use the same but am getting this error message:
{
"code": null,
"detail": "url signature missing or invalid",
"duration": "6ms",
"exception": "AuthenticationFailed",
"status_code": 403
}
Is this the right way to use this API?
I am using this from Java code and believe that the Java client doesn't have this functionality built in.
There's two ways to do this. You can do it manually from the explorer on the dashboard. Search for the feed, select an activity and press the truncate feed button. This is the easiest way to do this if manually doing this is sufficient.
It's also possible like you found to use the delete API endpoint to do it programmatically. This endpoint is not built in to most clients, including the Java client. The URL and HTTP verb that you used should indeed work.
From what I can tell from your headers and the response it seems like you are having an issue with supplying a correct signature. The easiest way to do this correctly is to use the built in methods in the library you're using to generate them. I'm not an expert in the Java library, but it seems like these methods are inside the StreamRepoUtils class.

Cannot display an overview of this response error in nexmo

i tried to run the code present in the below link
https://github.com/linroex/Nexmo-PHP-Library/blob/master/NexmoMessage.php
but i am getting cannot display overview of this response.warning Invalid argument supplied for foreach() in NexmoMessage.php on line 228.
or else please suggest some api to be used to send sms to phone using php which could be implemented easily
Check out https://docs.nexmo.com/tools/libraries for a list of libraries Nexmo recommends. Personally I'm a fan of https://github.com/fillup/nexmo since I wrote it, but I'm sure https://github.com/appleboy/CodeIgniter-Nexmo-Message is great too. If you try the fillup/nexmo library and have any issues let me know, will be glad to help.

Getting pronunciation of a word using Google Translate API

I am trying to save the pronunciation of a French word into a .wav or .mp3 file.
I was wondering if there was anywhere on the Google Translate API (since it has a pronunciation functionality) that allows me to achieve this objective. Other libraries would work too.
Since this question was asked, it's gotten much harder to "scrape" MP3s from Google Translate, but Google has (finally) set up a TTS API. Interestingly it is billed in input characters, with the first 1 or 4 million input characters per month being free (depending on whether you use WaveNet or old school voices)
Nowadays to do this using gcloud on the command line (versus building this into an app) you would do roughly as follows (I'm paraphrasing the TTS quick start). You need base64, curl, gcloud, and jq for this walkthrough.
Create a project on the GCP console, or run something like gcloud projects create example-throwaway-tts
Enable billing for the project. Do this even if you don't intend to exceed the freebie quota.
Use the GCP console to enable the TTS API for the project you just set up.
Use the console again, this time to make a new service account.
Use any old name
Don't give it a role. You'll get a warning. This is okay.
Select key type JSON if it isn't already selected
Click Create
Hold onto the JSON file that your browser downloads
Set an environment variable to point at that file, e.g. export GOOGLE_APPLICATION_CREDENTIALS="~/Downloads/service-account-file.json"
Get the appropriate access token:
Tell gcloud to use that new project: gcloud config set project example-throwaway-tts
Set a variable TTS_ACCESS_TOKEN=gcloud auth application-default print-access-token
Put together a JSON request. I'll give an example below. For this example we'll call it request.json
Lastly, run the following
curl \
-H "Authorization: Bearer "$TTS_ACCESS_TOKEN \
-H "Content-Type: application/json; charset=utf-8" \
--data-raw #request.json \
"https://texttospeech.googleapis.com/v1/text:synthesize" \
| jq '.audioContent' \
| base64 --decode > very_simple_example.mp3
What this does is to
authenticate using the default access token for the project you set up
set the content type to JSON (so that jq can extract the payload)
use request.json as the data to send using curl's --data-raw flag
extract the value of audioContent from the response
base64 decode that content
save the whole mess as an MP3
Contents of request.json follow. You can see where to insert your desired text, adjust the voice or change output formats via audioConfig:
{
'input':{
'text':'very simple example'
},
'voice':{
'languageCode':'en-gb',
'name':'en-GB-Standard-A',
'ssmlGender':'FEMALE'
},
'audioConfig':{
'audioEncoding':'MP3'
}
}
Original Answer
As Hugolpz alludes, if you know the word or phrase you want (via a previous Translate API call), you can get MP3s from a URL like http://translate.google.com/translate_tts?ie=UTF-8&q=Bonjour&tl=fr
Note that &tl=fr ensures that you get French instead of the default English.
You will need to rate-limit yourself, but if you're looking for a small number of words or phrases you should be fine.
Similar functionality is provided by the Speech Synthesis API (under development). Third-party libraries are already there, such as ResponsiveVoice.JS.

Resources