Hi Everyone,

I just want to know that can I implement a Facebook api on my server? It means all the facebook feature should be display in my server. Please anyone have any knowledge about this featured had provided by facebook then please guide me.

Thanks
Dheeraj

Recommended Answers

All 10 Replies

Yes it could be done. I doubt that many people would want to login off of your server though. Too much phishing going on these days.

Hi Everyone,

I just want to know that can I implement a Facebook api on my server? It means all the facebook feature should be display in my server. Please anyone have any knowledge about this featured had provided by facebook then please guide me.

Thanks
Dheeraj

In general, to access remote HTTP Based API's, PHP needs to allow outgoing socket connections. This is a setting in PHP.ini named "allow_url_fopen" (I'm quite sure thats what its called). Most hosting will have this setting to yes but a few shared hosting will not allow it.

Other than that, I don't believe you need anything else.

What you need to do to be sure, is download any sample PHP scripts they may have and test it on your server.

Most the time, sample scripts provided by API providers will use CURL, which is less availalbe on shared hosting then PHP sockets/streams. So you can always replace any CURL with the native PHP equivalents such as fsockopen(), fopen(), file_get_contents() etc.

Only other thing I can think of that would require more than basic PHP is if they require secure HTTP such as Secure Socket Layers (SSL) or some form of encryption not built directly into core PHP. This would then require extra libraries to be compiled into PHP. PHP supports open source libs for most all the major security enhancements of HTTP. It just depends on your ability to install them on your system.

Basically my question is that can i do call the Facebook API and showing the result in my server or not. The scenario is that we can make the request and call FB API as a client and When FB Server get back the response to my server then we can display all the responded result in HTML format to in my server.

Basically my question is that can i do call the Facebook API and showing the result in my server or not. The scenario is that we can make the request and call FB API as a client and When FB Server get back the response to my server then we can display all the responded result in HTML format to in my server.

You Can. (Unless your PHP install does not allow outgoing socket connections).

Just looked at the Facebook API briefly.

It looks like the login is the only thing that has to be implemented by the facebook website and not your application. You have to generate an Authentication Token for a user, then pass this token to facebook.com/login.php. After the user authenticates, you then request the users sessionid through an API Request.

After that, you just include the users sessionid in each request to facebook's api. You'll get results that you can then embed in your HTML.

Thanks digital-ether,

Did you have any example, because i couldn't understand how we can display user profile details? FB Server returned only $userId then we should pass this $userId in FBML "<fb:name uid='".$userId.
"' useyou='false' possessive='false'/>" and FBML could only parse by the FB Server. And my server couldn't capable to rendered the FBML to HTML. That's the problem currently i faced it.

Thanks digital-ether,

Did you have any example, because i couldn't understand how we can display user profile details? FB Server returned only $userId then we should pass this $userId in FBML "<fb:name uid='".$userId.
"' useyou='false' possessive='false'/>" and FBML could only parse by the FB Server. And my server couldn't capable to rendered the FBML to HTML. That's the problem currently i faced it.

To get user info you have to use the "facebook.users.getInfo" method I believe. Pass it the userid and get the info.

I think you don't need to parse the FBML on the server side. I haven't read the docs, but I don't see why they would put this complexity on the developer. Instead you'd probably just parse the FBML to the client side that load's a widget or something like that in place of it. (I really don't want to read their docs on a proprietary XML format that is supposed to make your life easier.. lol)

If you really have to parse FBML then you should be able to with PHP. FBML is just XML.
see: http://www.php.net/xml

Why not just use their REST API?

If you use their REST API it may be simpler. REST is very simple and is a standard. FBML means a learning curve for something you cant use on other projects.

Hi digital-ether,

Thanks for your kind of guidance. I going to try to do it. I will get back the response as soon.

Once again thanks.

Dheeraj

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.