i uploaded image to facebook using facebook SDK example. It looks like as show below :
image after uploading to facebook
image before uploading to facebook which is on my server
is anyone facing same problem with the image after uploading image on facebook?? If so how to solve this problem?
I am using the same code which is given in Facebook-Android Example:
HttpURLConnection conn= (HttpURLConnection)uploadFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
int length = conn.getContentLength();
byte[] imgData =new byte[length];
InputStream is = conn.getInputStream();
is.read(imgData);
params.putByteArray("picture", imgData);
Thanks in advance, aby
Related
I am new in android app Development my task is to upload data to localhost server that a user will (fill a form & press submit button to) upload.Tell also if any library is needed.
thanks in advance.
Are you using an HTML page? If so it is like a normla html page where you have a form with your fields and a submit button.
If you have, instead, a UI and wants to upload the data to a remove server there are several options:
Manually
Using some library (OkHttp or Volley)
If you want to do it manually:
HttpURLConnection con = (HttpURLConnection) ( new URL(url)).openConnection();
con.setRequestMethod("POST");
con.setDoInput(true);
con.setDoOutput(true);
con.connect();
con.getOutputStream().write( ("name=" + name).getBytes());
InputStream is = con.getInputStream();
byte[] b = new byte[1024];
while ( is.read(b) != -1)
buffer.append(new String(b));
con.disconnect();
Hope it helps you!
If you like i wrote a post about it in my blog
So I want my app to scrape some data from various sites, and one of them shows a recaptcha.
I was able to detect it in my app but I'm having problems figuring out a way to show the captcha to the user. The site is loaded in background with AndroidHttpClient.
I did some research and found nothing that could help me accomplish this for a third party site. The captcha needs to be solved and my quasi-browser (the androidhttpclient which just loads a bunch of sites in background) needs to get access to the site to gather the needed data.
I'm doing a similar project and I used a bitmap to capture the image (captcha) e show to the user in Android.
public Bitmap getCodigoCaptcha(String src){
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream inputStream = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(inputStream);
return myBitmap;
}
catch(Exception e){
e.printStackTrace();
return null;
}
}
I get this bitmap from the url that I need and set a ImageView in Android to show to the user.
Why not use a TSimpleCaptcha or JCaptcha?
I am trying to develop an application where I can get the HTML source of any web page. I am able to get the code but when I am trying the same code using some facebook profile links, it gives me an empty string.
I am using HttpURLConnection. I am trying the code as follows:
URL url = new URL(urlPassed);
HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
BufferedInputStream buffer = new BufferedInputStream(urlc.getInputStream());
and I am trying to read that buffer in a loop as buffer.read(by) where "by" is a byte array of size 7024. However, it works fine for all other web pages except facebook pages.
Any reason for this? Any idea to solve this?
I'm trying to get a users facebook profile pic using the FB api.
My way of doing this isn't working... first I make a request like this:
String str = facebook.request("me/picture");
Next I create an inputstream from the string str so I can decode it with a bitmapfactory
InputStream is = new ByteArrayInputStream(str.getBytes());
Bitmap bm = BitmapFactory.decodeStream(is);
iv.setImageBitmap(bm);
This never displays the image!
Haven't been able to find much about this. Any help would be appreciated.
I fixed this by just using HTTPGet to the url The first time I tried it I got a 404 error but when I rewrote it it worked!
The following steps allow me to fetch an image kept on my TomCat server. but i am unable to access an image from google's web site . What could be the reason ?
URL aURL = new URL(url);
URLConnection con = aURL.openConnection();
con.connect();
InputStream is = con.getInputStream();
/* Buffered is always good for a performance plus. */
BufferedInputStream bis = new BufferedInputStream(is);
/* Decode url-data to a bitmap. */
bm = BitmapFactory.decodeStream(bis);
bitmapDrawable = new BitmapDrawable(bm);
My URL :http://172.29.26.34:8080/MyService/hb.gif
Google image :
http://www.google.co.in/imgres?imgurl=http://www.androidguys.com/wp-content/uploads/2010/04/android_apps.jpeg&imgrefurl=http://www.androidguys.com/2010/04/25/hardware-standards-android-handset-manufacturers-implement/&usg=__VCGb9CrKDVzOjFJxQ0yFHGewblk=&h=356&w=570&sz=156&hl=en&start=0&sig2=N3UL3C995r94inBx8X822w&zoom=1&tbnid=wISGPUJqRDxB7M:&tbnh=127&tbnw=165&ei=h3-ITKDXMov0vQOsg7GPCQ&prev=/images%3Fq%3Dandroid%2Bimages%26um%3D1%26hl%3Den%26sa%3DN%26biw%3D963%26bih%3D525%26tbs%3Disch:1&um=1&itbs=1&iact=rc&dur=188&oei=h3-ITKDXMov0vQOsg7GPCQ&esq=1&page=1&ndsp=15&ved=1t:429,r:2,s:0&tx=107&ty=75
It is because the google link you pasted is the link for an image viewer in a frame, not for the picture itself. (And actually, strictly speaking the image is not from google website, it was just indexed and displayed by google)
In the right column there is a link 'view full size picture' to go to the real image.
If you use pictures from the web on your website, be sure to check the license if it is acceptable to do so or seek permission.
Set User-Agent
URLConnection con = aURL.openConnection();
con.setRequestProperty("User-Agent","");