Facebook从php

时间:2016-08-08 11:43:23

标签: php facebook api notifications facebook-php-sdk

我想建立一个有facebook通知的网站。我试图向帐户发送通知。 这是我的代码:

require 'Facebook/autoload.php';

    $facebook = new Facebook\Facebook(array(
      'appId'  => FB_APP_ID,
      'secret' => FB_APP_SECRET,
    ));


    $post = $facebook->api('/' . $user['uid'] . '/notifications/', 'POST/v2.2/',  array(
      'access_token' => FB_APP_ID.'|'.FB_APP_SECRET,
      'href' => "http://mydomainlink.com",  //this does link to the app's root, don't think this actually works, seems to link to the app's canvas page
      'template' => 'Max 180 characters',
      'ref' => 'Notification sent '.date("Y-m-d G:i:s") //this is for Facebook's insight
    )); 

结果:

  

致命错误:未捕获的异常'Facebook \ Exceptions \ FacebookSDKException',消息'必需'app_id“密钥未在配置中提供,并且无法在/ var / www / webpages / Facebook / Facebook中找到后备环境变量”FACEBOOK_APP_ID“。 php:133 Stack trace:#0 /var/www/webpages/fbnotify.php(14):Facebook / Facebook-> __ construct(Array)#main {main}引自/ var / www / webpages / Facebook / Facebook。第133行的PHP

用户使用facebook登录网站,因此我可以从那里获得用户ID。

0 个答案:

没有答案