在Heroku上部署Fb应用程序

苏拉夫

我是Heroku的新手。有时候,我一直试图在Heroku上为Fb部署应用程序,但未见成功。我曾尝试在互联网上寻找解决方案,但没有找到任何分步指南,所以我在这里问。

我的Fb应用程式程式码“ index.php”

<?php
session_start();
require_once __DIR__ . '/fbsdk/autoload.php';

$fb = new Facebook\Facebook([
'app_id' => '************',
'app_secret' => '**********',
'default_graph_version' => 'v2.4',]);
 $helper = $fb->getCanvasHelper();
 $permissions = ['email']; 

try {
if (isset($_SESSION['facebook_access_token'])) {
$accessToken = $_SESSION['facebook_access_token'];
} else {
    $accessToken = $helper->getAccessToken();
}
} catch(Facebook\Exceptions\FacebookResponseException $e) {
} catch(Facebook\Exceptions\FacebookSDKException $e) {
}

if (isset($accessToken)) {

if (isset($_SESSION['facebook_access_token'])) {
    $fb->setDefaultAccessToken($_SESSION['facebook_access_token']);
} else {
    $_SESSION['facebook_access_token'] = (string) $accessToken;
    $oAuth2Client = $fb->getOAuth2Client();
    $longLivedAccessToken = $oAuth2Client->getLongLivedAccessToken($_SESSION['facebook_access_token']);
    $_SESSION['facebook_access_token'] = (string) $longLivedAccessToken;
    $fb->setDefaultAccessToken($_SESSION['facebook_access_token']);
}

try {
    $request = $fb->get('/me');
} catch(Facebook\Exceptions\FacebookResponseException $e) {
    if ($e->getCode() == 190) {
        unset($_SESSION['facebook_access_token']);
        $helper = $fb->getRedirectLoginHelper();
        $loginUrl = $helper->getLoginUrl('https://apps.facebook.com/APP_NAMESPACE/', $permissions);
        echo "<script>window.top.location.href='".$loginUrl."'</script>";
        exit;
    }
} catch(Facebook\Exceptions\FacebookSDKException $e) {
}

try {
    $requestPicture = $fb->get('/me/picture?redirect=false&height=300'); 
    $requestProfile = $fb->get('/me');
    $picture = $requestPicture->getGraphUser();
    $profile = $requestProfile->getGraphUser();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
} catch(Facebook\Exceptions\FacebookSDKException $e) {
}

echo "<img src='".$picture['url']."'/>";
} else {
$helper = $fb->getRedirectLoginHelper();
$loginUrl = $helper->getLoginUrl('https://apps.facebook.com/APP_NAMESPACE/');
echo "<script>window.top.location.href='".$loginUrl."'</script>";
 }

“ composer.json”

 {}

我在Git Bash上使用的命令

heroku create AppName
mkdir AppName
cd AppName
git init
git add .
git commit -m "comment"
heroku git:remote -a AppName
git push heroku master

git branch
git commit -am "comment"
git push heroku master

一切顺利,heroku编译了PHP文件,部署了该文件。但是,当我直接打开Fb应用程序或什至heroku应用程序地址时,它会显示** 403 Forbidden”消息fbapp-2.herokuapp.com

目录结构 在此处输入图片说明

Buildpacks设置为heroku / php,
我没有procfile或.htaccess文件

heroku日志显示

State changed from starting to up
2016-04-05T15:30:14.413923+00:00 heroku[router]: at=info method=GET path="/"             host=fbapp-2.herokuapp.com request_id=ea94baf1-a433-4631-bbe5-7493cb7e137f   wd="43.230.135.148" dyno=web.1 connect=0ms service=3ms status=403 bytes=373
2016-04-05T15:30:14.399879+00:00 app[web.1]: [Tue Apr 05 15:30:14.395964 2016] [autoindex:error] [pid 82:tid 139840075028224] [client 1.3.2.3:58066] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive
2016-04-05T15:30:14.400023+00:00 app[web.1]: 1.3.2.3 - - [05/Apr/2016:15:30:14 +0000] "GET / HTTP/1.1" 403 209 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 OPR/36.0.2130.46
2016-04-05T15:30:14.873648+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=fbapp-2.herokuapp.com request_id=8b65b3b6-2f82-4ab4-abb4-d4849c1ec225 fwd="43.230.135.148" dyno=web.1 connect=0ms service=1ms status=404 bytes=373
2016-04-05T15:30:14.856297+00:00 app[web.1]: 1.3.2.3 - - [05/Apr/2016:15:30:14 +0000] "GET /favicon.ico HTTP/1.1" 404 209 "http://fbapp-2.herokuapp.com/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 OPR/36.0.2130.46
克里斯·卢瑟福

您收到的错误日志表明您的应用程序不在Heroku服务器上的/ app目录中,并且该目录中没有任何内容可供使用。尝试将整个应用程序从Web根目录移至/ app目录,看看如何解决,应该解决您的问题,如果不使用更新的错误日志进行回复。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在 Heroku 上部署 React 应用程序

无法看到在Heroku上部署Ruby on Rails应用程序?

Quarkus应用程序在Heroku问题上部署

在heroku上部署Spring MVC Web应用程序

在Heroku上部署Sinatra应用程序出错

Sails.js应用程序无法在Heroku上部署

在Heroku上部署打字稿应用程序,执行错误

在heroku上部署CodeIgniter Php应用程序

如何在Heroku上部署Webpack应用程序?

无法在 Heroku 上部署 Node.js 应用程序

在 Heroku 上部署多模块 java 应用程序

在 Heroku 上部署以 nginx 作为代理的 Springboot 应用程序

在 heroku 上部署 typeorm/typescript 应用程序

Erro 在 heroku BCryptPasswordEncoder 上部署应用程序

在heroku上部署golang应用程序,构建成功但应用程序错误

在heroku上部署Meteor 1.0应用程序后出现应用程序错误

在Heroku上部署MEAN应用程序时出现应用程序错误

在heroku上部署的django rest框架应用程序上的应用程序错误

在Azure上部署角度应用程序

在Linux上部署Qt应用程序

在Tomcat上部署Web应用程序

在IIS上部署角度应用程序

在IIS上部署PHP应用程序

在Azure上部署React应用程序

在 AWS 上部署 lambda 应用程序

无法在Websphere上部署应用程序

尝试在Heroku上部署Node.js / Express / Socket.io应用程序时出现应用程序错误

在Heroku上部署应用程序时过时的yarn lockfile错误

在 Heroku 上部署 Express 应用程序错误:找不到模块“/app/server.js”