Post Images to Facebook

Tutorials with advanced 'difficulty' and more Lines of Code.

Post Images to Facebook

Postby firestruck » Fri Dec 24, 2010 10:59 pm

Hi there, im getting problems to put a picture in the post of my App,in Facebook!The text Post works Great but Image dont load, can you help me?
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import java.awt.BorderLayout;
  2. import java.awt.Toolkit;
  3. import java.awt.image.BufferedImage;
  4. import java.io.BufferedInputStream;
  5. import java.io.File;
  6. import java.io.IOException;
  7. import java.io.InputStream;
  8. import java.net.MalformedURLException;
  9. import java.net.URL;
  10. import java.net.URLConnection;
  11. import java.text.SimpleDateFormat;
  12. import java.util.Date;
  13.  
  14. import javax.imageio.ImageIO;
  15. import javax.swing.ImageIcon;
  16. import javax.swing.JFrame;
  17. import javax.swing.JLabel;
  18.  
  19. import com.sun.medialib.mlib.Image;
  20.  
  21. import net.xeomax.FBRocket.FBRocket;
  22. import net.xeomax.FBRocket.Facebook;
  23. import net.xeomax.FBRocket.LoginListener;
  24. import net.xeomax.FBRocket.ServerErrorException;
  25. import android.app.Activity;
  26. import android.content.Context;
  27. import android.graphics.Bitmap;
  28. import android.graphics.BitmapFactory;
  29. import android.graphics.Canvas;
  30. import android.graphics.drawable.Drawable;
  31. import android.os.Bundle;
  32. import android.os.Handler;
  33. import android.os.Message;
  34. import android.os.Handler.Callback;
  35. import android.util.AttributeSet;
  36. import android.view.Gravity;
  37. import android.view.View;
  38. import android.view.ViewGroup.LayoutParams;
  39. import android.webkit.WebView;
  40. import android.widget.ImageView;
  41. import android.widget.LinearLayout;
  42. import android.widget.ProgressBar;
  43.  
  44. public class TestRocket extends Activity implements LoginListener {
  45.  
  46.         public FBRocket fbRocket;
  47.  
  48.  
  49.  
  50.         public static String currentFileName ;
  51.  
  52.  
  53.  
  54.         public final String images[] = {"http://safesport.site40.net/tv.jpg"};
  55.  
  56.  
  57.         @Override
  58.         public void onCreate(Bundle savedInstanceState) {
  59.                 super.onCreate(savedInstanceState);
  60.  
  61.                 shareFacebook();
  62.  
  63.  
  64.         }
  65.  
  66.  
  67.  
  68.         public void shareFacebook() {
  69.                 fbRocket = new FBRocket(this, "test",
  70.                 "ommited");
  71.  
  72.                 if (fbRocket.existsSavedFacebook()) {
  73.                         fbRocket.loadFacebook();
  74.                         return;
  75.                 } else {
  76.                         //fbRocket.login(R.layout.testrocket);
  77.                         fbRocket.login(R.layout.testrocket);
  78.  
  79.                 }
  80.         }
  81.  
  82.  
  83.         public void onLoginFail() {
  84.                 fbRocket.displayToast("Login failed!");
  85.                 //fbRocket.login(R.layout.correr);
  86.         }
  87.         public String setFileName(String filename) {
  88.                 // TODO Auto-generated method stub
  89.                 TestRocket.currentFileName = filename;
  90.  
  91.                 return filename;
  92.         }
  93.  
  94.         public void onLoginSuccess(Facebook facebook) {
  95.  
  96.                 SimpleDateFormat sdf = new SimpleDateFormat("dd:MM:yyyy");
  97.                 SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm:ss");
  98.                 String data = sdf.format(new Date());
  99.                 String time = sdf1.format(new Date());
  100.  
  101.                 try {
  102.  
  103.  
  104.  
  105.                         facebook.setStatus("Start Walk:"+time+"\n"+ "Day:"+data+"\n"+"Where:"+"\n"
  106.                                         +"http://maps.google.com/?q=http://safesport.site40.net/"+currentFileName);
  107.                         fbRocket.displayToast("Status Posted Successfully!! ");
  108.                         return ;
  109.                 } catch (ServerErrorException e) {
  110.                         if (e.notLoggedIn()) {
  111.                                 fbRocket.login(R.layout.ciclismo);
  112.  
  113.  
  114.                         } else {
  115.                                 System.out.println(e);
  116.                         }
  117.  
  118.                 }
  119.  
  120.  
  121.         }
  122. }
  123.  
  124.  
  125.  
  126.  
  127.  
Parsed in 0.045 seconds, using GeSHi 1.0.8.4


Tks in advance!Merry Christmas!Best
firestruck
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Dec 24, 2010 7:05 pm

Top

Return to Advanced Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests