me/feed not posting to facebook wall - android

My facebook wall posting AND checkins were working until last week... Now they have stopped working. it is really strange... I am not sure what is causing it.
I can login to facebook fine. That is proven because I can receive my facebook profile picture.
At the top of the class extending activity I have specified these fields:
private static final String APP_ID = "286529654765268";
private static final String[] PERMISSIONS = {"publish_stream", "publish_actions", "publish_checkins", "create_event"};
private static final String TOKEN = "access_token";
private static final String EXPIRES = "expires_in";
private static final String KEY = "facebook-credentials";
private Facebook facebook = new Facebook(APP_ID);
I use the facebook object throughout my class.
This is how I post a message:
defaultMessage = edittext.getText().toString();
String response = null;
try{
SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences("settings", 0);
String imageUrl = "www.somesite.com/somejpg.jpg";
Bundle params = new Bundle();
params.putString(Facebook.TOKEN, facebook.getAccessToken());
params.putString("caption", defaultMessage);
params.putString("description", "a description");
params.putString("picture", imageUrl);
params.putString("name", "A Name");
//
response = facebook.request("me/feed", params, "POST");
facebook.request("me/feed", params, "POST");
} catch(Exception e){
e.getStackTrace();
}
if(response != "false" || response != null){
Toast.makeText(getApplicationContext(), "Status Updated Successfully!", Toast.LENGTH_LONG).show();
Log.e("facebook response", response);
}
I authorize onCreate. Here is where I do it:
public void facebookAuthorize(){
facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, new DialogListener() {
#Override
public void onComplete(Bundle values) {
String me = null;
String id = null;
try {
me = facebook.request("me");
} catch (MalformedURLException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
JSONObject json_id = null;
try {
json_id = new JSONObject(me);
} catch (org.json.JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
id = json_id.getString("id");
} catch (org.json.JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.e("Id", id);
URL img_value = null;
try {
img_value = new URL("http://graph.facebook.com/"+id+"/picture?type=large");
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Bitmap mIcon1 = null;
try {
mIcon1 = BitmapFactory.decodeStream(img_value.openConnection().getInputStream());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if(mIcon1 != null){
badge.setImageBitmap(mIcon1);
}
Toast.makeText(getApplicationContext(), "Successfully logged in!", Toast.LENGTH_LONG).show();
}
#Override
public void onFacebookError(FacebookError error) {}
#Override
public void onCancel() {}
#Override
public void onError(com.facebook.android.DialogError e) {
// TODO Auto-generated method stub
}
});
if(restore(facebook, getApplicationContext())){
//authorize the user.
facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, new DialogListener() {
#Override
public void onComplete(Bundle values) {
Toast.makeText(getApplicationContext(), "Successfully Logged In to facebook!", Toast.LENGTH_LONG).show();
}
#Override
public void onCancel() {}
#Override
public void onFacebookError(com.facebook.android.FacebookError e) {
e.printStackTrace();
if(facebook.isSessionValid()){
Toast.makeText(getApplicationContext(), "Successfully Logged in to Facebook!", Toast.LENGTH_LONG).show();
// download the users avatar
}
else{
Log.e("FACEBOOK FAIL", "Facebook has epicly failed with an error in onCreate in Social Sharing or you are logged in already");
}
}
#Override
public void onError(com.facebook.android.DialogError e) {
// TODO Auto-generated method stub
}
});
} else { save(facebook, getApplicationContext()); }
}
I do not get an error. It appears to work but does not appear on my wall.
I get a facebook response with a post id too... The application is not blocked from posting on my profile.
Im at my wits end trying to figure out the issue. Any help would be great!.

I get a facebook response with a post id too...
What response do you get if you try to look up your post via that id?
If you can see your post this way, then it’s just not displayed on your wall (for reasons such as hiding/deleting previous posts, negative app feedback, …)

Related

unfortunately android application has been stopped. At Http Post while attempting to call server

Unfortunately android application has been stopped. At Http Post while attempting to call server at post activity please help
HttpClient cli = new DefaultHttpClient();
//HttpPost post = new HttpPost("http://" + sp.getString("ip", "localhost") + "/attendance/cliLogin.php");
HttpPost post = new HttpPost("localhost/attendance/");
// seting post data
List<NameValuePair> loginData = new ArrayList<NameValuePair>(2);
loginData.add(new BasicNameValuePair("uname", uname));
loginData.add(new BasicNameValuePair("pass", pass));
post.setEntity(new UrlEncodedFormEntity(loginData));
// executing login
HttpResponse res = cli.execute(post);
HttpEntity resent = res.getEntity();
String result = EntityUtils.toString(resent);
// reading response
if(result.equals("NoParams"))
Commons.showToast("Something went wrong", true);
else if(result.equals("Login"))
{
navi = new Intent(this, HomeActivity.class);
startActivity(navi);
}
else
Commons.showToast(result, true);
}
catch (HttpHostConnectException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Commons.showToast("Can't reach server, check the Hostname", true);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
Commons.showToast("Username/Password can't be empty", true);
}
}
Could you please share your logcat to see the error? I think that your are calling the php script in your main thread (that is your activity thread) and you may have NetworkOnMainThreadException
If that is the case:
Create a class that extends the AsyncTask.
Override its methods.
In the creator of this class pass the variables and assign them to the fields (variables) of your class.
Make your post in an AsyncTask inside the doInBackground method
And call the AsyncTask execute. Like this:
public class MyTask extends AsyncTask<String,String,String>{
private short errorType = -1;
private String result;
private String uname;
private String pass;
public MyTask(String uname, String pass){
this.uname = uname;
this.pass = pass;
}
#Override
protected String onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
if (errorType == 1){
Commons.showToast("Can't reach server, check the Hostname", true);
}
if(result.equals("NoParams")) {
Commons.showToast("Something went wrong", true); }
else if(result.equals("Login")) {
Intent navi = new Intent(this, HomeActivity.class); startActivity(navi);
}
else {
Commons.showToast(result, true);
}
}
#Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
}
#Override
protected String doInBackground(String... params) {
try
{
HttpClient cli = new DefaultHttpClient();
HttpPost post = new HttpPost("localhost/attendance/");
List<NameValuePair> loginData = new ArrayList<NameValuePair>(2);
loginData.add(new BasicNameValuePair("uname", uname));
loginData.add(new BasicNameValuePair("pass", pass));
post.setEntity(new UrlEncodedFormEntity(loginData));
// executing login
HttpResponse res = cli.execute(post);
HttpEntity resent = res.getEntity();
return result = EntityUtils.toString(resent);
}
catch (HttpHostConnectException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
errorType = 1;
return null;
}
catch (ParseException e) {
// TODO Auto-generated catch block e.printStackTrace();
errorType = 2;
return null;
}
catch (IOException e) {
// TODO Auto-generated catch block e.printStackTrace();
errorType = 3;
return null;
}
catch(Exception e){
errorType = 4;
return null;
}
}
}
And inside the activity make your call like this:
MyTask new MyTask(uname, pass).execute();
Again. All this is applicable only if you have
NetworkOnMainThreadException
Please share your logcat for further help.

How to Integrate Yahoo in Android

I'm very new to android development & I'm developing a yahoo login integration in Android App and return into main Activity. I have completed all the steps of yahoo integration.I have spent several days for searching yahoo integration in android but i cant find proper way.When i run this Application the Toast will appear consist of message:-
(E/Communication with the service provider failed: null(4194): oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: null)
then dialog box will appear with OAuth pin....Kindly any one help me about from where I get the OAuth pin and how can I retrieve yahoo mails by this Integration.
package com.example.yhoointegration;
public class MainActivity extends ActionBarActivity {
private static final String REQUEST_TOKEN_ENDPOINT_URL = "https://api.login.yahoo.com/oauth/v2/get_request_token";
private static final String ACCESS_TOKEN_ENDPOINT_URL = "https://api.login.yahoo.com/oauth/v2/get_access_token";
private static final String AUTHORIZE_WEBSITE_URL = "https://api.login.yahoo.com/oauth/v2/request_auth";
private static final int PIN_DIALOG = 0;
String CALLBACK_URL = ""; // this should be the same as
// the
// SCHEME and HOST values in
// your AndroidManifes""t.xml file
String CONSUMER_KEY = "";
String CONSUMER_SECRET = "";
private CommonsHttpOAuthConsumer myConsumer;
private CommonsHttpOAuthProvider myProvider;
private String requestToken;
private String accessToken;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
callOAuth();
showDialog(PIN_DIALOG);
}
private void callOAuth() {
try {
// retrieve the consumer token and then sign it
myConsumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY,
CONSUMER_SECRET);
myConsumer.setMessageSigner(new HmacSha1MessageSigner());
HttpClient client = new DefaultHttpClient();
// retrieve the provider by using the signed consumer token
myProvider = new CommonsHttpOAuthProvider(
REQUEST_TOKEN_ENDPOINT_URL, ACCESS_TOKEN_ENDPOINT_URL,
AUTHORIZE_WEBSITE_URL, client);
myProvider.setOAuth10a(true);
String aUrl = myProvider.retrieveRequestToken(myConsumer,
CALLBACK_URL);
requestToken = myConsumer.getToken();
Log.e("Token///", "" + requestToken);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(aUrl)));
} catch (Exception ex) {
Toast.makeText(getApplicationContext(), ex.getMessage(),
Toast.LENGTH_LONG).show();
Log.e(ex.getMessage(), ex.toString());
}
}
// this is the callback function that will run when oauth authenticates
// successfully
#Override
protected void onNewIntent(Intent intent) {
System.out.println("OnNewIntent...");
Toast.makeText(getApplicationContext(), "OnNewIntent - It works!",
Toast.LENGTH_LONG).show();
// whatever you want to do after authenticating goes here ....
}
AlertDialog createPinDialog() {
LayoutInflater factory = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
// LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.pin, null);
final EditText pinText = (EditText) textEntryView
.findViewById(R.id.pin_text);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Twitter OAuth PIN");
builder.setView(textEntryView);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
if (pinText != null)
gotOAuthPin(pinText.getText().toString());
onResume();
}
});
return builder.create();
}
private void gotOAuthPin(String pin) {
SharedPreferences.Editor editor = getSharedPreferences("yahoo",
MODE_PRIVATE).edit();
try {
myProvider.retrieveAccessToken(myConsumer, pin);
accessToken = myConsumer.getToken();
} catch (OAuthMessageSignerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OAuthNotAuthorizedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OAuthExpectationFailedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OAuthCommunicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (accessToken != null && accessToken.length() > 0) {
Toast.makeText(this, "Authorized", Toast.LENGTH_SHORT).show();
HttpPost request = new HttpPost(
"http://social.yahooapis.com/v1/user/profile?format=json");
StringEntity body = null;
/*
* try { body = new StringEntity("city=hamburg&label=" +
* URLEncoder.encode("Send via Signpost!", "UTF-8")); } catch
* (UnsupportedEncodingException e1) { // TODO Auto-generated catch
* block e1.printStackTrace(); }
* body.setContentType("application/x-www-form-urlencoded");
* request.setEntity(body);
*/
try {
myConsumer.sign(request);
} catch (OAuthMessageSignerException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (OAuthExpectationFailedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (OAuthCommunicationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("Sending update request to Fire Eagle...");
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = null;
try {
response = httpClient.execute(request);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Toast.makeText(
this,
"Response: " + response.getStatusLine().getStatusCode()
+ " " + response.getStatusLine().getReasonPhrase(),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Not Authorized", Toast.LENGTH_SHORT).show();
}
}
#Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case PIN_DIALOG:
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.pin, null);
final EditText pinText = (EditText) textEntryView
.findViewById(R.id.pin_text);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("OAuth PIN");
builder.setView(textEntryView);
builder.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
if (pinText != null)
gotOAuthPin(pinText.getText().toString());
}
});
return builder.create();
}
return super.onCreateDialog(id);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}

status update on facebook without dialog Android

Im using facebook-android-sdk-3.5.2, I want to post a message on facebook wall by clicking on button without showing dialog, I have tried many codes, some are saying "to post without dialog use Graph Api" but I don't understand how to use graph api. Some hav also given this solution which not work with me and not showing any error.
String message = "weLcom3";
Bundle parameterss = new Bundle();
parameterss.putString("message", message);
try {
fb.request("feed", parameterss, "POST");
} 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();
}
Try this it may help you, I am able to post without dialog box to facebook by this
String response;
try {
String msg="your message to be posted";
response = facebook.request("me");
Bundle b=new Bundle();
b.putString("message",msg);
b.putString("description", "Test test test");
response=facebook.request("me/feed",b, "Post");
if (response == null || response.equals("") || response.equals("false"))
{
System.out.println("Blank Response");
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
This is what I use:
Request request = new Request(session, "me/feed", parameterss,
HttpMethod.POST, checkincallback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
Request.Callback checkincallback = new Request.Callback() {
public void onCompleted(Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
// error
} else {
//succeeded
}
}
};
}

How to post on Facebook page's wall in Android?

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();
}
}

facebook status update

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.

Categories

Resources