我创建了Facebook应用程序(用于测试目的)并在公共模式下更改。我可以通过我的应用程序提供和分享。但是其他用户不能这样做,他们会得到像
这样的错误{
"error": {
"message": "(#200) The user hasn't authorized the application
to perform this action",
"type": "OAuthException",
"code": 200
}
}
我已添加权限" publish_actions"在许可中(我使用图API)。
当我第一次登录确认页面时显示消息
以下权限尚未获准使用,并且未向使用您的应用的人员显示:publish_actions(提交以供审核或了解详情。)
请在开发者页面中分享有关应用配置步骤的详细信息。
我的代码在这里:
登录功能
private static final String[] PERMISSIONS ={"publish_actions","email"};
@SuppressWarnings("deprecation")
public void login()
{
sh = getSharedPreferences("mydata", 0);
String access_token = sh.getString("access_token", null);
Long expire = sh.getLong("expire", 0);
if(access_token!=null)
fb.setAccessToken(access_token);
if(expire!=0)
fb.setAccessExpires(expire);
if(!fb.isSessionValid())
fb.authorize(this,PERMISSIONS,new DialogListener(){
@Override
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
Editor e = sh.edit();
e.putString("access_token", fb.getAccessToken().toString());
e.putLong("expire", fb.getAccessExpires());
e.commit();
Log.d("Token", fb.getAccessToken().toString());
Log.d("expire",Long.toString(fb.getAccessExpires()));
Profile();
}
@Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
}
@Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
}
@Override
public void onCancel() {
// TODO Auto-generated method stub
}
});
}
//for image post
@SuppressWarnings("deprecation")
public void ImageandTextupload()
{
byte[] data = null;
Bitmap bi = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
ByteArrayOutputStream b = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.JPEG, 100, b);
data = b.toByteArray();
Bundle param = new Bundle();
param.putByteArray("picture", data);
param.putString("message", "this is test post");
param.putString("description", "description");
param.putString("caption", "caption");
param.putString("name", "anand");
param.putString("link","http://google.com");
sh = getSharedPreferences("mydata", 0);
String access_token = sh.getString("access_token", null);
param.putString(Facebook.TOKEN, access_token);
asyn.request("/"+user_id+"/feed", param, "POST",new RequestListener(){
@Override
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
Log.d("Photo_response",response);
}
@Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
// TODO Auto-generated method stub
}
@Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub
}},null);
}
答案 0 :(得分:1)
自2014年4月起,大多数权限(包括publish_actions
)必须获得批准才能为其他用户工作。有关流程的信息,请参阅此链接:https://developers.facebook.com/docs/apps/review
查看更改日志也很重要:https://developers.facebook.com/docs/apps/changelog