代表Facebook页面发帖时出错

时间:2018-09-21 07:22:29

标签: facebook facebook-graph-api facebook-apps facebook-permissions

我有一个应用程序,可以以编程方式在已配置的Facebook页面上发布信息。 我的应用程序显然具有已批准的manage_pages和publish_pages权限,并且我正在使用页面访问令牌 Screenshot of the App Review section from Facebook dashboard

从现在开始,一切正常,但是最近当我在页面供稿上发布

try {
    String styleClass = null;
    Method getStyleClass = component.getClass().getMethod("getStyleClass");
    if (getStyleClass != null) {
        styleClass = (String)getStyleClass.invoke(component, (Object[])null);
    }
    Method setStyleClass = component.getClass().getMethod("setStyleClass", String.class);
    if (setStyleClass != null) {
        String newStyleClass = StringUtil.isNotEmpty(styleClass) ? styleClass.concat(" my-class") : "my-class";
        setStyleClass.invoke(component, newStyleClass);
    }
} catch (SecurityException e) {} 
catch (NoSuchMethodException e) {}
catch (IllegalArgumentException e) {}
catch (IllegalAccessException e) {}
catch (InvocationTargetException e) {}

我收到此错误:

/**
 * Intent to Send SMS
 * 
 *
 * Extras:
 *
 * "subject"
 *      A string for the message subject (usually for MMS only).
 * "sms_body"
 *      A string for the text message.
 *  EXTRA_STREAM
 *      A Uri pointing to the image or video to attach.
 *
 *  For More Info:
 *  https://developer.android.com/guide/components/intents-common#SendMessage
 *
 * @param phoneNumber on which SMS to send
 * @param message text Message to send with SMS
 */
public void startSMSIntent(String phoneNumber, String message) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    // This ensures only SMS apps respond
    intent.setData(Uri.parse("smsto:"+phoneNumber));
    intent.putExtra("sms_body", message);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}

我知道Facebook已经弃用了publish_actions范围,因此不再可能以编程方式在个人供稿上发布,但是我无法找出页面上的帖子为何返回这种错误。 一些其他信息:

  • 使用开发者帐户发布信息确实有效
  • 获取页面访问令牌的用户在Facebook上创建了该页面(因此我认为它是该页面的管理员)
  • 我最近从graph_api v2.12迁移到了v.3.1

任何建议将不胜感激 谢谢

2 个答案:

答案 0 :(得分:0)

我发现某些页面存在问题。 现在看来,如果用户授予manage_pages和publish_pages权限,则该权限仅对已经存在的页面有效!

新页面没有默认授予的权限。

解决此问题的唯一方法是从用户个人资料中删除我的应用程序(Facebook设置>业务集成>选择应用程序>删除),然后使用Facebook OAuth权限对话框再次提示用户。

我不知道是否有办法以编程方式强制删除应用程序,但我找不到。

答案 1 :(得分:-1)

您可以使用以下URL:

https://graph.facebook.com/v7.0/234002440799692/feed?&access_token={access_token}
相关问题