ykc
ykc

Reputation: 271

Facebook Apps (PHP base) on Google App Engine

I just finish a apps of facebook which developed with PHP, and now I'm looking for a FREE web host, after some googling, I found that some people claim they can run the application successful with Google App Engine(GAE), however, after I follow the step on these pages

http://raivoratsep.com/42/running-quercus-php-on-app-engine/ http://php-apps.appspot.com/

I can run some basic php script, but when I include the facebook.php (require 'facebook.php') and run on facebook, it seems something wrong was happened, nothing display.

Please help if someone have experience on facebook on GAE with PHP.

Thanks a lots~!

YK

Upvotes: 2

Views: 983

Answers (4)

Tiago Gouvêa
Tiago Gouvêa

Reputation: 16760

YES, you cand use it from GAE.

You just need to use this branch of the SDK, that uses http stream otherwise CURL.

https://github.com/camfitz/facebook-php-sdk

I'm using it and working fine!

Upvotes: 0

MarkokraM
MarkokraM

Reputation: 990

I tracked only one problem with PHP on GAE, which is very common indeed. It doesnt support https calls with curl.

Often this is easily solved by changing url to http because for example in case of Google OpenID [1] and Facebook sdk calls their end have redirects to https anyway. So a quick fix for Facebook class [2] is to either change $DOMAIN_MAP https to http or replace string on getUrl method

$url = str_replace('https://', 'http://', self::$DOMAIN_MAP[$name]);

In addition to that you need to pick up exception thrown on _graph method and add

if ((string)$e == 'OAuthException: You must use https:// when passing an access token') return $result;

before throw $e;

In some cases you probably need to set $_SERVER['HTTPS'] = 'off'; but I havent run all unit tests provided by Facebook yet...

If you are not forced to use CURL then you could use URLFetch trick with Java on PHP scripts:

import java.net.URL;
define('URLFetchServiceFactory', new Java('com.google.appengine.api.urlfetch.URLFetchServiceFactory'));
echo URLFetchServiceFactory->getURLFetchService()->fetch(new URL('https://www.google.com/'))->getContent();

It lacks huge feature list provided by curl, but works well on simple cases.

Upvotes: 1

You can see possible errors if you set:

error_reporting(E_ALL); ini_set('display_errors', 1);

somewhere at the beginning in your scripts.

Upvotes: 1

Sarfraz
Sarfraz

Reputation: 382776

There is not much you can do with GAE with PHP at the moment. A free alternative is to go for:

They provide you FREE:

  • MySQL Support
  • FTP
  • SVN
  • and a lot more...

Upvotes: 2

Related Questions