Not able to post on facebook wall in every one minute - android

I am developing one android application , in that application i want to post message on facebook in every 1 minute.
There is no problem in my code . In Every one minute i call the following method and it call successfully everytime , but in facebook i am not able to see all the post, facebook can only show the post after every ten minutes.
Code .
public void postOnWall(String msg)
{
try
{
if(mFacebook != null)
{
String response = mFacebook.request("me");
Bundle parameters = new Bundle();
parameters.putString("message", msg);
parameters.putString("description", "");
response = Profile.mFacebook.request("me/feed", parameters,"POST");
if (response == null || response.equals("") || response.equals("false"))
{
Log.v("Error", "Blank response");
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
Can you tell me what is the exact problem , why i can't see all the post on wall ? I can only see the post of every 10 Min.

Related

Facebook android SDK 3.0 - NullPointerException at .getInnerJSONObject()

I'm using Facebook SDK 3.0 (final release) for Android. I'm getting a NullPointerException at .getInnerJSONObject() at times (not always) when i try to post a new status on logged in user's feed. Following is the code i'm using inside new Request.Callback(){}:
public void onCompleted(Response response) {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.d("", "JSON error "+ e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(SessionLoginSampleActivity.this, error.getErrorMessage(), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(SessionLoginSampleActivity.this, "Post successful " + postId, Toast.LENGTH_LONG).show();
}
}
If there was an error in the request, response.getGraphObject() returns null.
Code using Response should always check that response.getError() returns null before accessing getGraphObject().
There are three constructors for Response: one that takes a GraphObject, one that takes a GraphObjectList, and one that takes a FacebookRequestError, and all fields are final. So only one of these can ever be non-null on any Response object.
I have experienced this and just to share what i have had, maybe the supplied url or link is invalid that is why it gives nullpointerexception.
Hope this will help others that can experience this situation.

Wall post doesn't appear on facebook posted by my application: Android

I am using Facebook API in my application to post messages to wall. Every thing work fine, but when I post message more than one time in a sort time interval, wall post doesn't appear on wall. I am sure there no any exception occurres while posting.
I use 'offline-access' permission with my application.
Code :
public static class UpdateWalls extends AsyncTask<String, Integer, Boolean> {
private Context context;
private String post;
public UpdateWalls(Context context, String post) {
this.context = context;
this.post = post;
}
#Override
protected Boolean doInBackground(String... strings) {
FacebookConnector facebookConnector = new FacebookConnector(Constants.FACEBOOK_APPID, context, Constants.FACEBOOK_PERMISSION);
try {
facebookConnector.postMessageOnWall(this.post);
} catch (Exception e) {
return false;
}
return true;
}
}
and FacebookConnector.postMessageOnWall() is
public void postMessageOnWall(String msg) {
if (facebook.isSessionValid()) {
Bundle parameters = new Bundle();
parameters.putString("message", msg);
try {
String response = facebook.request("me/feed", parameters,"POST");
Log.i("Facebook wall post", "While posting to wall response = " + response);
//System.out.println(response);
} catch (IOException e) {
e.printStackTrace();
}
} else {
//login();
}
}
Is this a known issue or something else? Please help me.
Thank you.
The Facebook API, in most cases, won't throw exceptions even if the request fails. Error status is returned by the response to the call. In this line here:
Log.i("Facebook wall post", "While posting to wall response = " + response);
You're writing a log with the response. What is that response? What is it when the wall post succeeds compared to when it fails?
It seems facebook reject requests when they come in too fast, see this question for a short but possibly out-of-date discussion on API limits. If you're getting a response that suggests you're making too many requests, you could add a delay and try again.

post NOT predifined messages on facebook wall from android application

I'm trying to create an android application which would allow the users to post messages on their facebook wall and also on their friends wall.
I've been through a few tutorials but in each of them is done barely the same thing:integrate facebook in application, the login authorization and posting a predifined message on the walll.
I'm using facebook sdk and I wonder is possible for the user to write directly to his wall in a dialog window???
What kind of authorization I need and if u could give me an example would be great.Thank u!
Take a look at this tutorial here and there is part 2 here. It will guide you though setting up the application to use facebook. Once you have all that setup you can use a function like this to post a msg to someones wall:
/**
* Post to a friends wall
* #param msg Message to post
* #param userId Id for friend to post to or null to post to users wall
*/
public void postToWall(String msg, String userID) {
try {
if (isSession()) {
String response = mFacebook.request((userID == null) ? "me" : userID);
Bundle parameters = new Bundle();
parameters.putString("message", msg);
response = mFacebook.request(((userID == null) ? "me" : userID) + "/feed", parameters, "POST");
Log.d(TAG,response);
if (response == null || response.equals("") ||
response.equals("false")) {
Log.v("Error", "Blank response");
}
} else {
// no logged in, so relogin
Log.d(TAG, "sessionNOTValid, relogin");
mFacebook.authorize(this, PERMS, new LoginDialogListener());
}
} catch(Exception e) {
e.printStackTrace();
}
}

how to to disable facebook feed dialog

I had used a facebook app to post message on wall from https://github.com/facebook/facebook-android-sdk.
Here after user allows the app to use his/her profile, dialog feed comes with an editable area to publish or skip. I want a predefined message there but user will not be able to modify it. I am able to send the predifined message but its editable. How to make it uneditable.
Does any one knows how to do it??
You can just use a function to post directly to the users wall. Just make sure that it is clear to the user that the button posts directly, perhaps use a dialog to get them to confirm they want to post. Here is the code I use:
/**
* Post to a friends wall
* #param msg Message to post
* #param userId Id for friend to post to or null to post to users wall
*/
public void postToWall(String msg, String userID) {
Log.d("Tests", "Testing graph API wall post");
try {
if (isSession()) {
String response = mFacebook.request((userID == null) ? "me" : userID);
Bundle parameters = new Bundle();
parameters.putString("message", msg);
response = mFacebook.request(((userID == null) ? "me" : userID) + "/feed", parameters, "POST");
Log.d(TAG,response);
if (response == null || response.equals("") ||
response.equals("false")) {
Log.v("Error", "Blank response");
}
} else {
// no logged in, so relogin
Log.d(TAG, "sessionNOTValid, relogin");
mFacebook.authorize(this, PERMS, new LoginDialogListener());
}
} catch(Exception e) {
e.printStackTrace();
}
}
The dialog contains a WebView that loads the actual content from a Facebook URL. So to modify the editable area, you would need to modify the DOM of this webpage. See this question for more information about doing that. It is unclear to me from the answers in that question if this is possible. If it is, you'll need to add the code to the FbDialog class in the Facebook Android SDK.

send an invitation to facebook friends to join my website

I have build an android application in which I've integrated faceboook using the facebook-sdk package.I've also succeded to retrieve in my application the name of all my facebook friends, their names and their id's.Further I want to send from my application an invitation to all facebook friends to join a website.Can u point me in the right direction cause I haven't found anything on the internet.Thank you
Try using the code below, if you follow the tutorials i gave you in your other question it will work no probs!
protected void postOfferToWall(String userID){
try {
if (isSession()) {
String response = mFacebook.request((userID == null) ? "me" : userID);
Bundle params = new Bundle();
params.putString("message", "message goes here");
params.putString("link", "http://mysite.com");
params.putString("caption", "Click the link");
params.putString("description", "description of link");
params.putString("name", "name of link");
params.putString("picture", "http://url.to.my.picture/pic.jpg");
response = mFacebook.request(((userID == null) ? "me" : userID) + "/feed", params, "POST");
Log.d("Tests",response);
if (response == null || response.equals("") ||
response.equals("false")) {
Log.v("Error", "Blank response");
}
} else {
// no logged in, so relogin
Log.d(TAG, "sessionNOTValid, relogin");
mFacebook.authorize(this, PERMS, new LoginDialogListener());
}
}catch(Exception e){
e.printStackTrace();
}
}
For a quick reference using the Graph API to post to your friends wall, see Graph API - Facebook Developers. There is a subsection called Publishing, where they use curl to post to a friends wall. Of course you need to get the access tokens and permissions to do such activities but it is all explained here.

Categories

Resources