I am having problem in updating status on facebook. I am using Facebook sdk, the problem is that my status is getting post but not showing text. Here is my code ---->
public class NetRockersUpdate extends AsyncTask{
#Override
protected String doInBackground(String... msg) {
// TODO Auto-generated method stub
nra = (NetRockersApp)getApplication();
String result = "Status Posted Successfully";
Bundle parameters = new Bundle();
parameters.putString("test", msg[0]);
parameters.putString("method", "stream.publish");
try {
nra.facebook.request(parameters);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
}
Check all the below post : I explained how to Post on User wall:
Post on User's Facebook Wall
Post to user Wall with Description,title,caption and link
Post on Wall..
you don't have a "message" key in your parameter.
Related
I have implemented facebook sdk in my android application and I have spent past 3hrs in downloading profile picture from facebook and yet i'm not successful in downloading it.
This is my code.
try {
String user = Facebuk.fb.request("me");
jsonObject = Util.parseJson(user);
String id = jsonObject.optString("id");
name = jsonObject.optString("name");
URL img_url = new URL("http://graph.facebook.com/" + id
+ "/picture?type=large");
dp = BitmapFactory.decodeStream(img_url.openConnection().getInputStream());
if (dp == null)
Log.i("", "afafaffgwgwgwg");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FacebookError e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
i get notified from the logcat that BitmapFactory.decodestream returns null
There were similar posts asked in Stack Overflow and there solution didn't workout for me.. please help me out.
Try using AQuery library which provides callback in which u get bitmap.
I follow one manual to upload images from Android to FTP. If I try to update a photo that have taken I can't see anything on the FTP file. It creates and the size is ok, but contains nothing. Then i try to upload one little image and this is the result:
(Random image to upload)
(Image uploaded)
The code: `class Sender extends AsyncTask
{
File photo;
public Sender(File photo){
this.photo=photo;
}
protected String doInBackground(String... params)
{
FTPClient ftpClient = new FTPClient();
try {
ftpClient.connect(InetAddress.getByName("ftp.fercode.com"));
ftpClient.login(xxx","xxx");
Boolean result = ftpClient.changeWorkingDirectory("/img");
Log.e("existeix carpeta?",result.toString() );
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
InputStream srcFileStream=null;
try {
srcFileStream = new FileInputStream(photo.getAbsolutePath());
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
//ftpClient.stor(photo.getAbsolutePath());
boolean status = ftpClient.storeFile("/img/imagePrueba.jpeg",
srcFileStream);
Log.e("Status", String.valueOf(status));
srcFileStream.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// TODO Auto-generated method stub
return null;
}
#Override
protected void onPreExecute()
{
super.onPreExecute();
}
#Override
protected void onPostExecute(String result)
{
// TODO Auto-generated method stub
super.onPostExecute(result);
}
}`
What I'm doing wrong? Thx a lot
That happens because I upload the image like ASCII and not binary. It's just a configuration parameter:
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
I am currently developing a web service that is using Node.js/ExpressJS and Passport for the login system. Everything is working fine on the web.
I would like to create an Android App that can be used to login to the server via httppost/JSON and get access to the user profile and all its variables.
Currently I am using a very stupid and unsecure approach.
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
Duan duan = ((Duan)getApplicationContext());
String output = "";
try {
output = new LoginTask().execute(jsonURL).get();
Log.v("JSON: ", output);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JSONObject jsonObject;
try {
jsonObject = new JSONObject(output);
String username = jsonObject.getString("username");
String user_id = jsonObject.getString("_id");
duan.setUserId(user_id);
duan.setUsername(username);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
As you can see, I am storing the _id and username field into a singleton that can be access across the application.
Is there a better and more secure way to program a log in system on android that works with Node.js and Passport?
Thanks,
Dennis
Hi I want to post any message or link to an Facebook page.What I have tried is this.
void postInfo()
{
try
{
Bundle parameters = new Bundle();
parameters.putString("message", messageFacebook);
parameters.putString("name", "Test Name");
parameters.putString("link", "http://www.mylink.com/");
parameters.putString("picture", imageUrl);
parameters.putString("display", "page");
String responsePost = facebook.request("me/feed", parameters, "POST");
String responsePagePost = facebook.request(FACEBOOK_PAGE_ID+"/feed", parameters, "POST");
Log.i(TAG, "responsePost = " + responsePost);
Log.i(TAG, "responsePagePost = " + responsePagePost);
} catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
What I am doing is I am posting a link to user's wall & also to my app's Facebook page.
This code works fine but problem is on Facebook page.The link which I post on Facebook page doesn't appear on page's wall but it appears on page's timeline in a box titled "Recent Posts by Others on MyApp Page".
I want the post should appear on wall rather than timeline.
What should I do I am not getting please help.
Facebook has changed all it's profiles to timelines now. Any facebook page will show posts by others as "Recent Posts by Others on MyApp Page". This behavior is controlled by facebook and not by your app. There is nothing you can do in this case.
Try this :
void postInfo()
{
try
{
Bundle parameters = new Bundle();
parameters.putString("message", messageFacebook);
parameters.putString("name", "Test Name");
parameters.putString("link", "http://www.mylink.com/");
parameters.putString("picture", imageUrl);
parameters.putString("display", "page");
facebook.dialog(this, "stream.publish", params,
new DialogListener() {
public void onFacebookError(FacebookError e) {
e.printStackTrace();
}
public void onError(DialogError e) {
// TODO Auto-generated method stub
e.printStackTrace();
}
public void onComplete(Bundle values) {
}
public void onCancel() {
}
});
} catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I have the code. No errors in eclipse. But in the emulator, I'm getting "Application has stopped unexpectedly" error. I have done a lot of research but I'm not able to get rid of this. All I want the app to do is to add events to my google calendar.
The code snippet:
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up the URL and the object that will handle the connection:
URL postUrl = null;
try {
postUrl = new URL("http://www.google.com/calendar/feeds/xyz#gmail.com/private/full");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
CalendarService myService = new CalendarService("exampleCo-exampleApp-1");
try {
myService.setUserCredentials("xyz","xyz123");
} catch (AuthenticationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
EventEntry myEntry = new EventEntry();
myEntry.setTitle(new PlainTextConstruct("test event"));
myEntry.setContent(new PlainTextConstruct("Working!!"));
Person author = new Person("It's me", null, "me#home.com");
myEntry.getAuthors().add(author);
DateTime startTime = DateTime.parseDateTime("2011-07-20T15:00:00-08:00");
DateTime endTime = DateTime.parseDateTime("2011-07-20T17:00:00-08:00");
When eventTimes = new When();
eventTimes.setStartTime(startTime);
eventTimes.setEndTime(endTime);
myEntry.addTime(eventTimes);
try {
EventEntry insertedEntry = myService.insert (postUrl, myEntry);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setContentView(R.layout.main);
}
Is it anything to do with the code or the manifest?