I followed this tutorial https://developers.google.com/youtube/v3/code_samples/java#search_by_keyword
to retreive youtube videos based on keyword using YouTubeData API
This section is giving me the error:
"Error:(117, 43) error: cannot find symbol variable auth"
youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, new HttpRequestInitializer() {
public void initialize(com.google.api.client.http.HttpRequest request) throws IOException {
}
})
.setApplicationName("youtube-cmdline-search-sample")
.build();
I think that this class is not being imported
import com.google.api.services.samples.youtube.cmdline.Auth;
I've searched the internet for someone else having this problem but the question was never answered....can someone please help me?
These two defines can be found in the youtube example:
Auth.java file from example
Are you can just replace the Builder string as follows:
new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), new HttpRequestInitializer()
This will do the trick, same as finding the defines.
Hopes this helps,
BR,
Adrian.
Related
I am hitting the following url from my android device.
URL : https://www.googleapis.com/youtube/v3/search?key=MY_KEY&channelId=UCoWgc1mqe-bcfb_lem7EyOg&part=snippet,id&order=date&maxResults=50
Response: ������������������]�r�8�}ϯ#e?䋕�}ɗ j����%OO(#�q3���*b�a"�g�o�K��%Y]�em�,uGd8m�ātu��]������/�c���W�_����B���M��;v�������q:��fA�[8KR�����lZ?[t]�JL���`�������G1����h䬑��T[}E�y�]qt�_xl��.��e/v�o���H
For getting the YouTube Videos List.It was working fine before but sometimes its response is not valid while hitting from browsers it works well.
Please help me !!
I found the solution i was using the loop j library (for http request) old version
just changes
compile 'com.loopj.android:android-async-http:1.4.8'
to
compile 'com.loopj.android:android-async-http:1.4.9'
it solved my problem
Please see my related question here (but in C#) and the answers on it in order to understand what I mean. Then you have to search example fordecompress gzip android and look at the existing resources to accomplish this.
Please keep in mind, that the API does not always send the response in gzip-format or not. So please do a check if the response is really in gzip.
For the plain decompression you can use the following method:
public static String decompress(byte[] compressed) throws IOException {
final int BUFFER_SIZE = 32;
ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
GZIPInputStream gis = new GZIPInputStream(bis, BUFFER_SIZE);
StringBuilder s = new StringBuilder();
byte[] data = new byte[BUFFER_SIZE];
int bytesRead;
while ((bytesRead = gis.read(data)) != -1) {
s.append(new String(data, 0, bytesRead));
}
gis.close();
bis.close();
return s.toString();
}
(this code was taken from Vyshnavi's answer)
Trying out something very basic in Twilio & C#. I am new to Twilio & I am not very strong with MVC
public class IncomingCallController : TwilioController
{
// GET: IncomingCall
[HttpGet]
public ActionResult Index()
{
var response = new VoiceResponse();
var dial = new Dial();
Response.ContentType = "text/xml";
response.Say("Please wait...transferring your call");
dial.Number("+919812345678");
return TwiML(response);
}
}
I need the above code snippet to return the static Twiml equivalent that I would have put in a Twiml bin.
I have configured the phone number to with a webhook url as
http://someaddress.azurewebsites.net/IncomingCall
Why am i getting an
11210-HTTP bad host name
error
I understand that I am doing something wrong here. I have tried using both a POST and GET request.
Can anyone who has knowledge of this point me in the right direction?
Where am I going wrong?
Any help would be appreciated.
Some issues are created by programmers who are in a tearing hurry....This was an issue created by yours truly..
Thanks to Phil's interaction I was able to find out...
I am using navigate().to() method to navigate but new url is getting appended to old url as below, after executing navigate.to function thus resulting in 404 error
https://www.google.co.in/www.yahoo.co.in
Can anyone please help how should I get this to work?
public static void main(String[] args) throws InterruptedException {
WebDriver fd = new FirefoxDriver();
fd.get("http://www.google.co.in");
Thread.sleep(3000);
fd.navigate().to("www.yahoo.co.in");
}
}
I'm not sure how to use navigate().to() but this an alternative solution.
import java.awt.Desktop;
import java.net.URI;
....
try {
Desktop d = Desktop.getDesktop();
d.browse(new URI("http://www.google.co.in"));
Thread.sleep(3000);
d.browse(new URI("www.yahoo.co.in"));
} catch (Exception ex) {
ex.printStackTrace();
}
There are two options:
1) use again get() method from the WebDriver to navigate to the new URL.
2) use navigate().to() method, but use fully qualified URL parameter. Eg. "https://www.google.com"
From the WebDriver javadoc: #param url The URL to load. It is best to use a fully qualified URL
The navigate() method is useful for using the context on the current web context. i.e. go back, forward.
Basically, the get() and navigate().to() do the same thing. I just tried both and they work.
Reference: http://www.seleniumeasy.com/selenium-tutorials/difference-between-webdriver-get-and-navigate
I have created a model and a view and displayed some needed data from the model using simple GameController.
Now i am searching(didn't found anything usefull) on how to get 9 images and show them in the page using ApiController(9 images that can be used for a puzzle) and modifying the page that GameController has returned, without loading the whole page.
The idea is that i want to call the method from ApiController 9 times and to show the images in a grid/table or somewhere.
I can use an example on how to do this since i didn't found something relevant on google and someone with knowledge can do it very fast.
If something is unclear, just ask.
Thanks,
Gabriel Sas
There is an example here:
public HttpResponseMessage GetImage()
{
HttpResponseMessage response = new HttpResponseMessage();
response.Content = new StreamContent(new FileStream(#"path to image")); // this file stream will be closed by lower layers of web api for you once the response is completed.
response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
return response;
}
public class ConsumeFactoryThread extends Thread {
private String url;
public ConsumeFactoryThread(String url){
this.url = url;
}
public void run(){
ConnectionFactory connFact = new ConnectionFactory();
ConnectionDescriptor connDesc;
connDesc = connFact.getConnection(url);
if(connDesc != null)
{
HttpConnection httpConn;
httpConn = (HttpConnection) connDesc.getConnection();
try
{
final int iResponseCode = httpConn.getResponseCode();
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
//data retrieved
}
});
}
catch(IOException e)
{
System.err.println("Caught IOException: " + e.getMessage());
}
}
}
}
I got the above code from one of Blackberry's articles, but I'm not entirely sure as to how I get the raw String of the contents of the url, which in my case is going to be a json string.
I know when I was not using ConnectionFactory I used an inputstream to get the data, but I don't know if it is the same with the newer api.
Thanks
I believe what you are looking to do is the following:
is = ((Connection) httpConn).openInputStream();
byte[] data = net.rim.device.api.io.IOUtilities.streamToBytes(is);
String result = new String(data);
This will grab the input stream the HttpConnection object has gathered, use the RIM IOUtils class to nicely put it into an array then finally create a String from the data. It should be possible from their to use the JSON libraries that RIM include in their SDK to work on the JSON.
Note: Not sure if the cast is required, btw this is untested code.
You should also note there are 3 different APIs which you can use to create a network connection on BlackBerry.
Using the Generic Connection Framework
The oldest methed (OS 5 below) is a basic J2ME implementation with additional transport descriptors appended to the end of the URL. It uses the J2ME GCF. A great explanation is given here, describing how to always reliably open a HTTPConnection.
Using the Network API
Introduced in OS 5 and above. This is the current method you are using. It wraps over the nasty descriptor Strings that are added to the end of the URL in the GCF through the use of the ConnectionFactory and ConnectionDescriptor classes.
Using the Communications API
Introduced into OS 6 and above. This is the newest possible method, it is an even higher abstraction on the Network API. These API's abstract how the actual data is gathered and try to not bother you with the details of the protocol. The useful thing about this API is you just get the resulting data and don't have to worry about the implementation details.
You should note that as you are working with JSON it even will wrap around the details of converting the resulting data and convert it into the format you wanted. An example is shown here.