This is my first time to try integrate my page with facebook login. I using the way shown in http://www.domagojsalopek.com/Details/Create-a-Registration-and-Login-System-using-Facebook-Registration-Plugin/21.
I did exactly the same as in the tutorial. I even downloaded the sample and tried, yet it did not work.
But once I filled in all the detail and clicked the 'Register' button, it went to 'Server Error' page. I found that the error came from the following line in register.php
$facebook = new Facebook(array(
'appId' => FB_ID,
'secret' => FB_SECRET,
));
Note: I had replace my ID and Secret in config.php.
I had the solution already. In the sample code it does not include the facebook.php.
Related
I'm using Kohana and I'm trying to make facebook login.
Where should I place appId in my project?
I put it in facebookauth/config/facebook file but it's still showing me previous AppId that I have used. Is there another place that I have to change it?
My code in config file is something like this:
return array(
'appId' => 'digits',
'secret' => 'ahgtdhdjsd',
'cookie' => true,
'redirect_uri' => URL::site(Request::current()->uri(), true)
And path to facebook login is :
https://www.facebook.com/dialog/oauth?client_id=OldAppId&redirect_uri=mysite.com&state=2df46b19d8c71f1976b3722d7e61a&scope=email&display=page
Đ•dited:
I found another file to change it-/config/facebook.
I placed the same code - appId, secred and cookie but now link is:
mysite.com/fbLogin?code=AQAfKFVji6aI0Xx1CtcW4JqKmj2LIY6Yx13BrHRfmUDIF2vpmBlNwSouBUAsCflXI9vImTc6gwurBmDKF9uub_MTmd3gRQmFP6LdiyVMJbJ0a9CSJKKcJR1BFftYajjK
What's wrong with it? It should be the same as the above link but only appId to be changed?
Can anybody help me?
Now that you have updated the other config file the code is working as expected. The URL you're seeing looks like you have already authorized your App with your personal Facebook account and were redirected by Facebook or are already logged in and don't need to be redirected by Facebook. Try clearing all your cookies or using another browser or incognito session to see what the flow looks like when you're not already logged in.
I know this question has been addressed many times but I am still facing problems, So I wanted to ask here if anyone can help.
I used facebook SDK to get the latest posts, here is the code below:
require "facebook.php";
$facebook = new Facebook(array(
'appId' => YOUR_APP_ID,
'secret' => YOUR_APP_SECRET,
));
$pageFeed = $facebook->api(THE_PAGE_ID . '/feed');
Then I print_r the results but I am getting feeds like [story] which contains information like I have added someone as a friend or I have post somewhere, but there is also an attribute [message] which contains my reply on some post.
Now 1st thing I am getting only 4 feeds where is I want 10 feeds.
2nd thing is what information I shall extract to show on my website as latest post feeds (story, message or some other attribute)? Keeping in mind that I do not have both of these fields in every array.
If there is something I may not have mentioned here kindly do ask.
Thanks.
You have to use posts instead of feed because feed includes user postings too.
You can test it in Graph Explorer with <your page id>/posts?limit=10 to get last 10 posts of your fanpage.
So your code should look like
require "facebook.php";
$facebook = new Facebook(array(
'appId' => YOUR_APP_ID,
'secret' => YOUR_APP_SECRET,
));
$pageFeed = $facebook->api(THE_PAGE_ID . '/posts?limit=10');
I have just started with the Facebook application development. I downloaded the PHP SDK from Facebook couple of weeks ago.
Following is the first piece of code which i wrote.
<?php
require 'src/facebook.php';
$app_id = 'My APP ID';
$application_secret = 'My APP Secret';
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $application_secret,
'cookie' => true, // enable optional cookie support
));
$uid = $facebook->getUser();
echo $uid;
?>
But it is always giving me 0 as a result even when i am already login into my facebook account in other tab.
My Canvas URL is pointing to my localhost as i have hosted this app on my local machine only.
I have read almost every post related to this issue but i was not able to solve this issue somehow.. It would be really helpful if anybody could help me in resolving this issue.
Cheers.
Ajay
The code will always return 0 unless you have authorised the app - even if you are logged into facebook elsewhere. Login to your app by going to the URL outputted by $facebook->getLoginUrl();
Then, you will find that $facebook->getUser() will return the correct User ID.
I'm just starting a new app with the php-sdk. I've done an app a few years ago, but this is the first time with the newer setup dialogs.
The canvas url is pointing to my web server and the app's subdirectory.
Right now this is the only code in my app...just the "hello world" from the php-sdk sample.
<?php
include 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'myappid',
'secret' => 'mysecret',
));
// Get User ID
$user = $facebook->getUser();
?>
Yes, the appid and secret are the actual numbers.
I've waited several minutes to propagate but when going to https://apps.facebook.com/myappsname it just tosses me a 404 error. Is there another URL I should go to when it's in sandbox?
To get https://apps.facebook.com/[APP_NAMESPACE] working, you must specify [APP_NAMESPACE] the App Namespace in the Dev App (https://developers.facebook.com/apps) under Basic settings.
I was developing facebook canvas application, and I found this simple code fails. I don't know what went wrong, because I took it straight from tutorial:
<?php
require 'facebook.php';
/*
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2;
*/
$facebook = new Facebook(array(
'appId' => 'xxx',
'secret' => 'xxx',
'cookie' => true,
));
//Request params
if(!($facebook->getSession()))
{
header("Location:" . $facebook->getLoginUrl(array('req_perms' => 'publish_stream')));
exit;
}
?>
the problem is at header("Location:" . $facebook->getLoginUrl(array('req_perms' => 'publish_stream')));. When I remove it (including removing the exit), the application can run well. However, when I have it, the application doesn;t show anything. Just blank page. And there is "load resource error from channel.facebook.com" on chrome's developer tools.
Can anybody help me spot what when wrong? I don't understand what went wrong In this code. I have made sure that appId and secret are correct.
This might help you:
load resource error from channel.facebook.com is irrelevant to your problem, I've seen that error plenty of times on the facebook page, it is their problem.
Most likely you are getting a blank screen because there is a PHP error, and you have error_reporting set to 0. Try error_reporting(E_ALL) to see if this is the problem.
Where is this code located, is the header you are sending ahead of other text output? Try placing the code on top of the page.
These are just some basic stuff you can check, hope it helps. Good luck.
I had the same problem (blank page) when trying to redirect (in PHP from the server side) to the login URL generated with the function getLoginUrl of the Facebook PHP SDK.
The problem seems to be related to the fact that the redirection is in the iFrame.
The redirection needs to be for the parent frame and not the canvas frame.
In PHP there is no way to tell the browser to redirect the parent frame soo you have to do it in Javascript:
$loginUrl = $facebook->getLoginUrl(array('req_perms' => 'publish_stream'));
echo '<script type="text/javascript">top.window.location="'.$loginUrl.'";</script>';