English 中文(简体)
促使Facebook PHP SDK在我的申请上工作的问题
原标题:Issues getting the Facebook PHP SDK to work on my application

I was making a facebook application in which i have to show news feeds of the user who is using it. I am using graph API to do this. The problem is that its not getting me feeds. I used it to show friends like this:

$friends = $facebook->api( /me/friends );

并且正在罚款。

供新闻参考的是:

$feeds   = $facebook->api( /me/home );

这表明我有了一个错误:

Fatal error: Uncaught IDInvalidException: Invalid id: 0 thrown in 
/home/content/58/6774358/html/test/src/facebook.php on line 560

当我试图通过下列方式获取简介资料时:

$feeds   = $facebook->api( /me/feed );

it shows me an empty array.

These API calls are showing me results in the graph API page but don t know why not working in my application.Can any one help me please.. My full code is as follows

require_once  src/facebook.php ;

// Create our Application instance. $facebook = new Facebook(array( appId => xxxxx , secret => xxxxx , cookie => true, ));

$session = $facebook->getSession();
    $fbme = null;
// Session based graph API call.
if (!empty($session)){
    $fbme = $facebook->api( /me );
}
if ($fbme) {
     $logoutUrl = $facebook->getLogoutUrl();
     echo  <a href=" .$logoutUrl. ">Logout</a> ;
}else{
    $loginUrl = $facebook->getLoginUrl();
     echo  <a href=" .$loginUrl. ">Logout</a> ;
}
$friends = $facebook->api( /me/friends?access_token= .$session["access_token"]);
$feeds   = $facebook->api( /me/feed?access_token= .$session["access_token"]); 
print( <pre>Herere: );print_r($feeds);die;
最佳回答

请问:>在认证期间是否获得下限?

http://developers.facebook.com/docs/authentication/"rel=“nofollow”>Authentication/“Allow”过程是你经过的?

Java SDK?book PHP SDK? XFBMLlogin Button?

http://www.ohchr.org。 在这方面,你将启动有益的联系:

https://github.com/facebook/php-sdk”rel=“nofollow>book PHP SDK

http://developers.facebook.com/docs/authentication/"rel=“nofollow”>Authentication Process

Building Apps onbook.com

这些都是在Facebook和github的正式笔记。


www.un.org/Depts/DGACM/index_spanish.htm 逐步落实这一步骤:

根据你原来的法典,研究:

$loginUrl = $facebook->getLoginUrl();

修改如下:

$loginUrl = $facebook->getLoginUrl(array( req_perms => read_stream ));

首先请您说明:

http://www.facebook.com/settings/?tab=applications

然后试图再次展示新的<>低 人口。


www.un.org/Depts/DGACM/index_spanish.htm

它还涉及在发言时的守则安排。 使用该守则:

<?php
require_once  src/facebook.php ;
$session = $facebook->getSession();
$fbme = null;

if($session){
    $fbme = $facebook->api( /me );
    $friends = $facebook->api( /me/friends );
    $feeds = $facebook->api( /me/feed ); 
    $logoutUrl = $facebook->getLogoutUrl();
    echo  <a href=" .$logoutUrl. ">Logout</a> ;
    echo "<pre>".print_r($feeds,TRUE)."</pre>";
}else{
    $loginUrl = $facebook->getLoginUrl(array( req_perms => read_stream , canvas =>1, fbconnect =>0));
    echo  <script> top.location.href=" .$loginUrl. "; </script>> ;
}

再次申明

http://www.facebook.com/settings/?tab=applications

重新启动申请

问题回答

“Facebook PHP SDK”应当处理你获得象征性服务的问题,你无需将其附在您的“密码”上。

@dragonjet指出,你需要请read_stream 。 允许FB用户获得食物。 虽然你所留下的例外实际上与这种问题不相称,而且你要求<代码>/me/home。 并没有出现类似的例外(或没有进入)。

我仍然认为这是一个许可问题,因此,从这里开始,试图加以纠正。 这里是请求适当许可的一个例子。

$facebook = new Facebook(array(
     appId  => FB_APP_ID, //put your FB APP ID here
     secret  => FB_APP_SECRET, //put your FB APP SECRET KEY here
     cookie  => true
));

$session = $facebook->getSession();

if ($session)
{
    //check to see if we have friends_birthday permission
    $perms = $facebook->api( /me/permissions );
}

 //we do this to see if the user is logged & installed
if (empty($session) || empty($perms[ read_stream ]))
{
    //get url to oauth endpoint for install/login
    $loginUrl = $facebook->getLoginUrl(array(
        //put the URL to this page, relative to the FB canvas
        //(apps.facebook.com) here vvv
         next  =>  http://apps.facebook.com/path_to_your_app/index.php ,
         req_perms  =>  read_stream 
    ));

    //use javascript to redirect. the oauth endpoint cant be loaded in an
    //iframe, so we have to bust out of the iframe and load it in the browser
    //and tell the oauth endpoint to come back to the fb canvas location
    echo "<script>window.top.location= {$loginUrl} ;</script>";
    exit;
}

print_r($facebook->api( /me/home ));
print_r($facebook->api( /me/feed ));




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签