Bir merhaba dünya facebook app Require_oncenin ile ilgili sorun

2 Cevap php

Facebook apps.I gelişen yeni Im sorunu şu var ve birisi yardımcı olabilir mutluluk duyarız.

Ben facebook benim app tescil ve barındırma sunucusuna kodu ve php istemci kütüphanesi yükledik. I aşağıdaki kodu kullanırsanız o zaman her şey çalışıyor.

<?php

require_once('./facebook/php/facebook.php');

/* initialize the facebook API with your application API Key
  and Secret */
$facebook = new Facebook("<my_api_key>","<my_secret_key>");

$user = $facebook->require_login();

echo "<p>Your User ID is: $user</p>";

echo "<p>Your name is: <fb:name uid=\"$user\" useyou=\"false\"/></p>";

echo "<p>You have several friends: </p>";
$friends = $facebook->api_client->friends_get();
echo "<ul>";

foreach ($friends as $friend)  {
echo "<li><fb:name uid=\"$friend\" useyou=\"false\" /></li>"; 
}
echo "</ul>";

/* Echo some information that will
  help us see what's going on with the Facebook API: */
echo "<pre>Debug:" . print_r($facebook,true) . "</pre>";


?>

I aşağıdaki gibi iki dosya içine kodu bölerseniz i http://apps.facebook.com/myapp gittiğinizde Ama, sonra ben sadece boş bir tuval olsun

appinclude.php

<?php
require_once('./facebook/php/facebook.php');

/* initialize the facebook API with application API Key
  and Secret */
$facebook = new Facebook("<my_api_key>","<my_secret_key>");

$user = $facebook->require_login();

?>

index.php

<?php

require_once('./appinclude.php');

echo "<p>Your User ID is: $user</p>";

echo "<p>Your name is: <fb:name uid=\"$user\" useyou=\"false\"/></p>";

echo "<p>You have several friends: </p>";
$friends = $facebook->api_client->friends_get();
echo "<ul>";

foreach ($friends as $friend)  {
echo "<li><fb:name uid=\"$friend\" useyou=\"false\" /></li>"; 
}
echo "</ul>";

/* Echo some information that will 
  help us see what's going on with the Facebook API: */
echo "<pre>Debug:" . print_r($facebook,true) . "</pre>";

?>

Bunu düzeltmek için herhangi bir şekilde?

Teşekkür ederiz.

2 Cevap

Benim app kurmak yolu hiçbir karışıklık yok yani aynı dizindeki tüm dosyaları sahip olmaktır.

/ Myapp / index.php

<?php
require_once('appinclude.php');
?>

/ Myapp / appinclude.php

<?php
require_once('facebook.php');
?>

Myapp dizinin bu gibi görünüyor:

/Myapp/jsonwrapper/JSON/JSON.php
/Myapp/jsonwrapper/JSON/LICENSE
/Myapp/jsonwrapper/jsonwrapper.php
/Myapp/jsonwrapper/jsonwrapper_inner.php
/Myapp/facebook.php
/Myapp/facebookapi_php5_restlib.php
/ Myapp / appinclude.php
/ Myapp / index.php

Ikinci örnekte düzen çalışması için böyle olması gerekir:

/facebook/php/facebook.php
/Myapp/AnotherDirectory/index.php
/ Myapp / appinclude.php

Appinclude.php ve index.php aynı klasörde değildir dikkat edin. index.php kendisi yukarıdaki dizinde bir dosya appinclude.php arar ve appinclude.php kendisi yukarıdaki dizinde bir dosya facebook / php / facebook.php arar. Eğer gerektiren ifadelerin ön noktalar ve eğik kaldırmak olsaydı aynı dizinde hepsi için bakmak istiyorum. Temelde ne gerçekleştirmek gerekir olduğunu. / require_once('./appinclude.php'); Bu bir üstündeki dizine bak diyor.

Ben dosya yollarını kontrol.

Bu 'facebook / php /' adında bir dizin bir dosya eklemek için çalışıyoruz ikinci (non-çalışan bir sürümü) olarak görünüyor.

Bu sizin uygulamanın root olarak belirttiğiniz dizin ise o zaman Facebook bu dizini seviyesinin altında dosyaları dahil etmek için izin vermez tahmin ediyorum.