using facebook connect for website on localhost - php

i am using Facebook connect user authentication for my website.i followed some simple tutorials but i couldn't able to make it.since i am using codeigniter and testing it on localhost.i need to know whether Facebook allow to redirect back on localhost or not.if it does then how to work with Facebook connect on local machine.please let me know if you have any solution.

You have to put localhost in your app settings in all the places where it want’s to know stuff like login URL, website, etc. – then it should work perfectly fine. (Except for those functions that actually need Facebook to connect your server, like deauthorize URL – put pure redirects happen client side, so there’s no problem there.)

I run a pure PHP project (so I don't know how you do this with CodeIgniter) and I got Facebook Connect working doing these 2 (that I remember; if don't, tell me and I revise :)
edited hosts file (c:\Windows\System32\drivers\etc\hosts or /etc/hosts) to redirect 127.0.0.1 to domain name you use
set <base href=".."> meta to
"http://{$_SERVER["HTTP_HOST"]}/"
then handle the URI you pass to Facebook Connect properly using the domain you set.
To test, access using http://<the-domain-name-set-in-hosts> and test normally. I guess that's it, and it's working here.

Related

Integrating youtube API in php on localhost

I'm developing a PHP app on my local computer and trying to use the public data API. The key has been generated and works well online, but as soon as I try to execute it on my localhost it returns
Access Not Configured. Please use Google Developers Console to activate the API for your project.
I have added these lines to the 'allowed referers' section in the developers console.
http://127.0.0.1
127.0.0.1
http://localhost/
localhost
http://myIpAddress
myIpAddress
None of them seem to help. This is the query sending via GET:
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=######&fields=items%2Fsnippet&key=#######
My issue had nothing to do with the cases described here, but might help others.
I had a scenario where the API worked well online but not on localhost (WAMP), after migrating from old API.
The fix had to do with cURL, and I really can not explain why it did work online, I am not an expert, it's something related with SSL.
Basically, you need to turn of SSL verification, by using
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
According to your answer #neki-doar-fraer, i make the explanation more clear for other viewers of this post :
From the doc of YouTube API
Use a server key if your application runs on a server. Do not use this
key outside of your server code. For example, do not embed it in a web
page. To prevent quota theft, restrict your key so that requests are
only allowed from your servers' source IP addresses.
Use a browser key if your application runs on a client, such as a web
browser. To prevent your key from being used on unauthorized sites,
only allow referrals from domains you administer.
From the Google Developer Console, assuming you have already created a project, select the project you are working on.
Then from the side menu on the left select "APIs & Auth", then "APIs". From that screen you have to search for the YouTube API and then click the "On" button next to it.
I figured it out. I was using the browser key. Did not know there is a difference. Generated the server key and everything works.
I have always edited my HOSTS file to point the domain to LOCALHOST when testing things locally https://en.wikipedia.org/wiki/Hosts_(file)

Using https with localhost wamp

I am trying to run facebook App from my localhost .I made the canvas URL and secure Canvas URL to http://localhost/myapp and https://localhost/myapp .but the link http://localhost/myapp doesn't even work at my localhost.I enable mode_ssl and php_openssl extentions as well.I read different tutorials on internet but all invain. Anyone who already tested facebook apps on localhost.
Thanks
If you want to do it properly, try following this tutorial:
http://www.phpjoel.com/2011/04/07/installing-ssl-using-openssl-on-a-wamp-localhost/
The issue isn't anything to do with Facebook, so just concentrate on getting it without facebook first.
I haven't bothered making a self signed certificate to test facebook apps, what I have done though is make sure secure browsing is turned off on facebook. Then you should be able to hit the http://localhost/myapp and it won't redirect you.

Permanent URL masking for mirroring website using php and htaccess

First
Let say that i have www.domain.com that are client site and user login and do all the thing that he want (site is main and he use POST method for login adn other things and HEADER redirect if login are success)
But i not want user to see original www.domain.com i want when they enter www.name.com/dashboard.php to see content from www.domain.com/dashboard.php but him URL bar to show www.name.com/dashboard.php ..and like this all other page that can have original www.domain.com
I found this site:
http://www.htmlremix.com/css/permanent-url-masking-for-mirroring-website-using-php-and-htaccess
Adn use script but when are entered user login detail noting happen!! Just home page reload.
I try everything that i think may be cause problem and not found how to solv it .. So please help me!!
Thanks Allot
P.S. If have some more good way that can i use also will help me!
that cant be achieve with a htaccess file.
You need different things.
possible solution could be:
apache mod proxy so you could proxy everything through that url.
the other way could be a php written some kind of proxy. Working with curl or and remote configured fopen.
But be careful to also send the post data and the cookies, otherwise the user session could not be handled if its cookie based.
If both domains are on the same server you could easily set this up with a vhost configuration in apache/nginx what ever you are using.

Other users cant login using facebook's api on localhost

I'm working with the PHP SDK on localhost. I've looked at other questions posted on here like this:
Can't login to website using facebook's api's
Domains, urls, login urls all match. The app secret and id match, sandbox was never turned on (double checked to make sure). I had trouble moving it to a new laptop, cuz the folder i put it in was called something else. After i changed that it worked fine.
The problem I'm having is, I as the owner of the app can log in and it does what i want it to do, but if i have a friend, or another user try to log in, it asks for permissions, then shows the "An error has occured, Please try later" facebook error page. Not entirely sure why its doing this, because i havn't hardcoded my info into it at all.
I've used different browsers, cleared cookies, nothing seems to work. Any ideas would be helpful.
EDIT: i've also tried destroying the session before login, didn't help.
Thank you.
Other people cannot access your app 'on localhost' if they are not using your computer, which is the local host.
If you want other people to be able to use your app, they'll need a copy of your code, running on their local machine, or you'll need to make it available via a publicly accessible IP and/or domain name.

FACEBOOK - integrating PHP SDK & JS SDK together - infinite refreshing

I have an weird issue with facebook connect.
I've tried to run the basic example for JS & PHP SDKs.
While I connect to FB account via connect page, on my localhost it works well but in my web server it's getting refreshed non-stop.
The example is from here: https://github.com/facebook/php-sdk/tree/master/examples
(with JS).
What may be the reason for it?
Check your app URL on your Facebook application settings. This has to match the URL of the script hosting your app. Otherwise it'll try to switch to the correct one.

Categories