无法使用新的API发送FB通知 [英] Can't send FB Notifications with new API

查看:73
本文介绍了无法使用新的API发送FB通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

真的需要一些帮助!

我正在尝试使用新的Notifications API从canvas应用程序发送通知,但我不断收到以下异常:

I'm trying to send notifications from a canvas app using the new notifications API but I keep getting the following exception:

OAuthException:(#200)仅Web画布应用程序可以发送应用程序通知

OAuthException: (#200) Only web canvas apps can send app notifications

但是,该应用程序已加载到Facebook画布中-当用户执行触发通知POST请求的特定操作时,我正在对服务器进行ajax调用.用户还授权了该应用.

However, the app IS loaded in the Facebook canvas -- I'm making an ajax call to my server when the user takes a particular action which triggers the notification POST request. The user has also authorized the app.

这是我正在使用的代码:

This is the code I'm using:

$graphUrl = $user_id . "/notifications";
$params = array( "access_token" => $admintoken,
             "href" => $link, 
         "template" => "string of text < 180 chars"
        );

try {
  $result = $facebook->_graph($graphUrl, 'POST', $params);
 } catch (Exception $e){
     echo $e;
 }

推荐答案

我也遇到了这个问题,这就是我解决的方法,但这可能与您无关,因为您似乎确定自己是Canvas应用程序. Mine是一款主要在Facebook上运行的应用程序,但是具有Facebook集成挂钩,这意味着用户可以授权我的Facebook App,然后通过Facebook框架接收有关有趣事件的更新.

I just ran into this too and this is how I solved it, but this may not be relevant to you as you seem certain yours is a Canvas app. Mine is an app that mostly runs off Facebook, but has Facebook integration hooks that means users can authorise my Facebook App and then receive updates about interesting events via the Facebook framework.

我去了Facebook Developers应用程序中编辑我的应用程序设置,在底部附近的Settings-> Basic页面上查看.我只选中了具有Facebook登录名的网站".我选中了"Facebook上的App",这为我提供了画布页面"和其他各种设置.填写并保存这些内容后,立即执行uid/notifications的POST.

I went to edit my App settings in the Facebook Developers app, look on the Settings->Basic page near the bottom. I only had "Website With Facebook Login" checked. I checked "App on Facebook" and this gave me a "Canvas Page" and various other settings. With these filled in and saved, the POST to uid/notifications worked immediately.

偶然地,转到apps.facebook.com/myappname此处失败,因为它重定向到https,并且对我的网站的请求失败,因为我的SSL设置不正确,但这并不能阻止在该应用程序凭据下发送通知

Incidentally, going to apps.facebook.com/myappnamehere fails because it redirects to https and the request to my site fails because my SSL isn't set up right, but this didn't prevent notifications being sent under that apps credentials.

这篇关于无法使用新的API发送FB通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆