Facebook应用通知PHP [英] Facebook App Notifcations PHP

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

问题描述

我一直在阅读Facebook开发者文档,我有些困惑,我想通过让他们稍微微动一下他们在我们应用程序上的不活动状态来重新吸引一些已经过时的用户...

目前这样做的最佳做法/最新方式"是什么,似乎是通过通知API进行的? https://developers.facebook.com/docs/app_notifications/#imp

如果我是对的,那么有人可以给我一些有关此实现的PHP实现的指针,实质上,这将是一个cron,每月运行一次,每两周一次,通过一段时间未登录的用户进行搜索,然后向他们求婚.

谢谢

马克

解决方案

好吧,因为没有人对此作出回应,这是我从文档中得出的一个简单可行的解决方案.要通知用户,他们必须授权您的应用.

$book = new Facebook((array(
'appId'  => 'XXXXXX',
'secret' => 'XXXXXX',
'grant_type' => 'client_credentials')
 ));

$vars = array(
"access_token" => $book->getAppId().'|'.$book->getApiSecret(),
"href" => "index.php", 
"template" => "Some text to send up to 180 characters",
"ref" => "This is what shows up in insights so you can track responses"
);

$post = $book->api('/' . $userid . '/notifications/', 'post', $vars);

您可以将用户名插入模板中,方法是使用{}将Facebook用户ID括起来,例如: "{12345}想和你一起玩一些游戏." .但是,如果uid指的是尚未对您的应用进行身份验证的用户,则会引发异常.

Href会自动将您的画布URL插入其前面,因此不需要完整的域/路径.

ref用于见解界面,因此您可以查看哪些通知正在产生流量!

就这样,重新吸引那些似乎已经消失的用户非常简单!

欢呼

马克

I've been reading through the facebook developer docs and i'm a little confused, I want to re-engage a load of users that have gone a little stale really by giving them a little nudge regarding their inactivity on our app...

What is the current "best practice/latest way" of doing this, it seems to be via the notifications API? https://developers.facebook.com/docs/app_notifications/#imp

If i'm correct can someone give me a couple of pointers for a PHP implementation of this, essentially it would be a cron running once a month/every two weeks wizzing through users who haven't logged in for a while and prodding them.

Thanks

Marc

解决方案

Well since nobody responded to this heres a simple working solution that I figured out from the docs. To notify a user they have to authorised your app.

$book = new Facebook((array(
'appId'  => 'XXXXXX',
'secret' => 'XXXXXX',
'grant_type' => 'client_credentials')
 ));

$vars = array(
"access_token" => $book->getAppId().'|'.$book->getApiSecret(),
"href" => "index.php", 
"template" => "Some text to send up to 180 characters",
"ref" => "This is what shows up in insights so you can track responses"
);

$post = $book->api('/' . $userid . '/notifications/', 'post', $vars);

You can insert user names into template by surrounding the facebook user id with {} ie: "{12345} would like to play some game with you." . It will throw an exception though if the uid refers to a user that hasn't authed your app.

Href automatically gets your canvas url inserted infront of it so no need to full domain/path.

ref is used in the insights interface so you can see which notifications are generating traffic!

Thats it, very simple to re-engage those users who seem to have disappeared!

Cheers

Marc

这篇关于Facebook应用通知PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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