By facebook default message post
#SuppressWarnings("deprecation")
public void postToWall() {
// post on user's wall.
facebook.dialog(this, "feed", new DialogListener() {
#Override
public void onFacebookError(FacebookError e) {
}
#Override
public void onError(DialogError e) {
}
#Override
public void onComplete(Bundle values) {
}
#Override
public void onCancel() {
}
});
}
we can share data but want to do the same thing with regular edit text and button,Is there any way to do this,please suggest me,thanku
this will help you.
Bundle parameters = new Bundle();
parameters.putString("message", "Test");
parameters.putString("description", "topic share");
facebook.request("me");
facebook.request("me/feed", parameters, "POST");
Related
Hello every i am working app where i have to send invitation of my app to my facebook friend.
My invitation successfully send but message is not showing to my friend whom i send the app request.
i follow this question which help in that but message is not showing to that user whom i send the app request.
here is my code:
Bundle parameters = new Bundle();
parameters.putString("to", fb2);
parameters.putString("message", "hello app ...");
Facebook mFacebook = new Facebook(APP_ID);
mFacebook.dialog(getParent(), "apprequests", parameters, new Facebook.DialogListener() {
#Override
public void onComplete(Bundle values) {
Toast.makeText(getParent(), "Invitation has been send", Toast.LENGTH_SHORT).show();
}
#Override
public void onCancel() {
}
#Override
public void onFacebookError(FacebookError e) {
}
#Override
public void onError(DialogError e) {
}
});
I have created a facebook event with my android coding and now I want to invite friends to it.
Below is my code to invite friends:
private void inviteFriends()
{
try
{
Bundle params = new Bundle();
params.putString("title", "invite friends");
params.putString("message", "come join us!");
facebook.dialog(this, "apprequests", params, new DialogListener() {
#Override
public void onComplete(Bundle values) {}
#Override
public void onFacebookError(FacebookError error) {}
#Override
public void onError(DialogError e) {}
#Override
public void onCancel() {}
public void onComplete(String response, Object state)
{
try
{
JSONObject eventResponse = new JSONObject(response);
//event_id = event.getString("id");
Log.i(TAG, "Event Response => "+eventResponse);
Log.w("myapp", friends);
//Toast.makeText(getApplicationContext(), "New Event Created!!", Toast.LENGTH_LONG).show();
}
catch (Exception e)
{
}
}
});
}
catch (Exception e)
{
}
}
The code works up to selecting friends, the title and message comes with the friend list. I can send the invitation but no notifications are sent to selected people.
Please tell me what needs to be done. Thank you in advance!
this image.
Have you turned on the App omn Facebbok Tab in your app developer setting like this.
If don't then it will not sent notification to your friends.
I got a problem while posting text message on the wall.
I expected the apps will login to fb and post a text message on the wall, but nothing is posted on my wall.
The following is my code
The login part is the same as the Facebook guide and i just added the permission "publish stream"
public class FB_trial extends Activity {
Facebook facebook = new Facebook("app_id");
private AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
private SharedPreferences mPrefs;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fb_trial);
/*
* The following is tutorial sample code
*/
mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if(access_token != null) {
facebook.setAccessToken(access_token);
}
if(expires != 0) {
facebook.setAccessExpires(expires);
}
/*
* Only call authorize if the access_token has expired.
*/
if(!facebook.isSessionValid()) {
facebook.authorize(this, new String[] {"publish_stream"}, new DialogListener() {
#Override
public void onComplete(Bundle values) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token", facebook.getAccessToken());
editor.putLong("access_expires", facebook.getAccessExpires());
editor.commit();
}
#Override
public void onFacebookError(FacebookError error) {}
#Override
public void onError(DialogError e) {}
#Override
public void onCancel() {}
});
}
//end of the login sample code
//post wall fx
Bundle params = new Bundle();
params.putString("message", "Fb testing message");
params.putString("access_token", access_token);
mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request("me/feed", params, "POST", new RequestListener(){
#Override
public void onComplete(String response, Object state) {
System.out.println("post wall success");
}
#Override
public void onIOException(IOException e, Object state) {}
#Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {}
#Override
public void onMalformedURLException(MalformedURLException e,
Object state) {}
#Override
public void onFacebookError(FacebookError e, Object state) {}
}, null);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_fb_trial, menu);
return true;
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
}
}
The "wall post success" message is shown in the log (is that means the request is complete?)
but i can't find the post on my wall.
You can use the dialog to post to wall:
Bundle params = new Bundle();
params.putString("link", linkgame);
params.putString("name", subject);
params.putString("description", content);
params.putString("picture", iconUrl);
facebook.dialog(((Activity) ctx).getParent(), "feed", params,
new DialogListener() {
public void onComplete(Bundle values) {
}
public void onFacebookError(FacebookError error) {}
public void onError(DialogError e) {}
public void onCancel() {}
});
I am Facebook sdk newbie , i need to create a apps
I know how to post to wall, check in , get friend ,
But i don't know how to get Profile feed (Wall) and friend feed
Need to use Graph API ??
But i don't understand Graph API how to use
With Facebook popup:
public void share(String day, String points)
{
Bundle params = new Bundle();
params.putString("name", XXXXXXXX);
params.putString("caption", XXXXXXXX);
params.putString("link", XXXXXXXX);
params.putString("description",XXXXXXXX);
facebook.dialog(this, "stream.publish",params , new WallPostDialogListener());
}
class WallPostDialogListener implements DialogListener
{
public void onComplete(Bundle values)
{
if(data.facebook == true)
{
Log.e("SHARE",values.toString());
if(values.getString("post_id")!=null)
{
}
}
}
public void onFacebookError(FacebookError e)
{
Log.d("PostToWall","Facebook Error");
}
public void onError(DialogError e)
{
Log.d("PostToWall","Dialog error");
}
public void onCancel()
{
Log.d("PostToWall","Cancel");
}
}
and without the Facebook dialog:
Bundle parameters = new Bundle();
parameters.putString("name", XXXXXXXX);
parameters.putString("message", XXXXXXXX);
parameters.putString("link", XXXXXXXX);
response = facebook("me/feed", parameters, "POST");
Try: https://developers.facebook.com/docs/reference/api/
For example:
(I don't know if this works)
Bundle parameters = new Bundle();
response = facebook("me/feed", parameters, "GET");
JSONObject feeds = new JSONObject();
try
{
feeds = new JSONObject(response);
}
catch(JSONException e)
{}
or:
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request("me/feed", new FeedsRequestListener());
private class FeedsRequestListener implements RequestListener
{
#Override
public void onComplete(String response, Object state)
{
try
{
JSONObject json = Util.parseJson(response);
}
catch (JSONException e)
{
Log.e("OnComplete","JSONException");
}
catch (FacebookError e)
{
Log.e("OnComplete","FacebookError");
}
}
#Override
public void onIOException(IOException e, Object state)
{
Log.e("FeedsRequest","onIOException " + e.toString());
}
#Override
public void onFileNotFoundException(FileNotFoundException e,Object state)
{
Log.e("FeedsRequest","onFileNotFoundException " + e.toString());
}
#Override
public void onMalformedURLException(MalformedURLException e,Object state)
{
Log.e("FeedsRequest","onMalformedURLException " + e.toString());
}
#Override
public void onFacebookError(FacebookError e, Object state)
{
Log.e("FeedsRequest","onFacebookError " + e.toString());
}
}
I am able to post facebook feed through Facebook Android SDK; however, I found that the feed dialog doesn't have privacy setting button, did I do anything wrong?
Bundle params = new Bundle();
params.putString("description", "This is description!");
params.putString("name", "appname");
params.putString("captions", "This is captions!");
params.putString("link", "http://www.google.com");
facebook.dialog(this, "feed", params,
new DialogListener() {
#Override
public void onComplete(Bundle values) {}
#Override
public void onFacebookError(FacebookError error) {}
#Override
public void onError(DialogError e) {}
#Override
public void onCancel() {}
}
);
You can configure privacy via params in facebook.dialog(this, "feed",params, ...) see here for details