I am somewhat confused by the facebook developers guide. Some tutorials show the javascript SDK being used while some show the PHP SDK being used. Do I need to load both of these? Are there any differences between the two (besides one being client and one being server)?
I am wanting to use Facebook's SDK for User Authentication, Social Plugins, and the Graph API.
The best advice I can give you - be very careful when planning a new development on the Facebook Platform. A lot of the documentation is seriously out of date, and this is exacerbated by sporadic platform revisions.
Admittedly, this has improved in recent months, but I digress...
Facebook have recently deprecated the creation of FBML canvas applications, which means your application will have to be in an iframe. This also implies you could make the applications available off of Facebook too (e.g., http://apps.facebook.com/someapp/ and http://www.someapp.com/ can both load up). This narrows the benefits of using the PHP SDK, as a lot of the functionality is available via the JavaScript API.
For SDK authentication you should use the Javascript SDK. It's much easier to set up things properly.
For the Graph API, it depends what kind of application you are going to build. If you are storing or processing stuff on the server side then you will have to use the PHP SDK.
You don't need to use an SDK for their Social plugins. You just have to copy-paste sample code in most cases.
Many tasks/calls can be done by javascript. I use both for my. 85% JavaScript and 15% PHP.
Reason: If you have an App with > 10000 dau's, the PHP SDK will suck sometimes, because every api-call needs at least 0.3s via cURL on my machine.
My Opinion: Use PHP SDK only if necessary
Related
I've a big social networking project going on and I am amateur in web back-end. Although I've programming experience, I'm a beginner in the back end support.
I was trying to make a login page and was thinking if I use Firebase to do the user authentication? Then I would use PHP to do rest of the things like chat system or post system.
Is it possible to do so? If yes, then how should I start a session in Firebase and use it in PHP?
You can definitely use Firebase Authentication in your web site that is otherwise written in PHP. Key to realize is that in this case there are two places you need to interact with Firebase:
From your client-side JavaScript code, you will use Firebase Authentication to sign in, and get an ID token.
From your server-side PHP code, you then verify the ID token. You can for example use the open-source Firebase Admin SDK for PHP library for that. Note that this is not an official Firebase SDK, but in my (limited) experience it works well.
The general process for this is also described in the Firebase documentation on verifying ID tokens, it just doesn't contain the PHP bits.
Alternatively you can just stay within the Firebase ecosystem, and not use a PHP server. For example, you can store your data in Cloud Firestore directly from the client. To get familiar with this approach quickly, I'd recommend taking the codelab where you build a web-based chat app.
I'm so frustrated right now. I spent so much time trying to debug my application to find out that the official PHP SDK from Facebook is out of date and doesn't look like it's maintained anymore: https://github.com/facebook/facebook-php-sdk
After lodging a bug to Facebook because of an error returned by the API, one of the employee at Facebook respond the following:
THe old REST API does not support use of Page Access Tokens, you need to use the Graph API for such API calls - if you're using an SDK, please ensure it's routing your FQL queries to https://graph.facebook.com/fql?q=X and not https://api.facebook.com/method/fql.query
However in the PHP SDK that Facebook provide it's using the following request:
URL: https://api-read.facebook.com/restserver.php
GET: method=fql.query&return_ssl_resources=1&query=SELECT+comment_info.comment_count%2C+created_time%2C+like_info.like_count%2C+permalink%2C+post_id%2C%0A+share_info.share_count%2C+type%2C+attachment.media%0A+FROM+stream%0A+WHERE+actor_id%3Dxxxxxx%0A+AND+source_id%3Dxxxxxx%0A+ORDER+BY+created_time+DESC%0A+LIMIT+100&callback=&api_key=xxxxxxxxx&format=json-strings&access_token=xxxxx
Anyone bumped into this issue? What SDK are you using instead?
The PHP SDK on Github is still maintained and the official source (see https://developers.facebook.com/docs/reference/php/)
Still, old API (like the REST api) are still supported for backward compatibility concerns. But for new stuff, you need to use the Graph API. If you read the documentation, it is very clear that the Graph API is the way to go (there's no mentions of REST api in the documentation). https://developers.facebook.com/docs/reference/php/facebook-api/
So, I think the issue here is you started of reading some old blog posts without reading the official APIs docs. Honestly, around Facebook stuff, only believe what you can find in the official documentation and on StackOverflow with a good vote rating. Too many bad developers have been trying to bring SEO to their websites writing shitty article on developing Facebook apps.
I'm very new to web development. I have searched for login with Google plus and found several good tutorials. But they seems to be very old (most of them from 2011). Why?
I tried below code chunks.
<script type="text/javascript" language="javascript">
$("#packagesGrid").load('https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=ya29.ahes6zt9yv2qaeej5ycn21fn9maokp15scwqkcal3guqxxez7odtjg&token_type=bearer&expires_in=3600');
</script>
I just manually copy pasted the token to the url on the jQuery load function. But nothing is filled to the page.
Google APIs use the OAuth 2.0 protocol for authentication and authorization. Google supports several OAuth 2.0 flows that cover common web server, JavaScript, device, installed application, and server to server scenarios. The Previous Versions of OAuth has been deprecated by Google.
Here is how it works : https://developers.google.com/accounts/docs/OAuth2
To Get Started with Coding,
https://code.google.com/p/google-plus-php-starter/
Just download the project and Follow the steps mentioned.
I have tried this recently and it's working 100% fine.
I'm in a Google presentation at the moment and apparently they have just launched Google+ sign-in, which allows you to do stuff like this much more elegantly.
I don't know any more about it than that, really, but it certainly seems worth a look.
I would suggest making use of the following tutorial Login with Google Account OAuth. It explains calling the correct methods and saves the user data to your database. Plus it was published today.
For this you have to use google client Api library for php
and after that, you need to generate some key (like client id, client secret key, simple API key for Google)
then you have to use these API and use the keys generated. You can find the complete procedure and documents at there corresponding websites...
If you neeed the working tutorial.
I have written a small web app with GWT and am looking into what it will take to make a "clone" of it on Facebook (as a FB app). After spending some time reading the dev docs it looks like a Facebook App is just a vanity canvas that points to another URL under the hood (via iframe).
All of the FB dev docs keep re-emphasizing PHP-centric development. Not that I have anything against PHP (!), it's just that I'd like to be able to point the FB app at my (existing) web app main screen and not have to re-write any code.
So... my question boils down to this: can I just iframe the FB app's canvas to my existing web app or do I have to totally re-write my app in PHP? Thanks in advance!
Like you said, it's just an IFrame, Facebook doesn't know what language you use. So you can use anything, although it has to support certain things like URL parameters.
The reason for the PHP documentation is because there is an an official PHP SDK, but no others in that area (There is a JS and smart phone SDK too), all other SDKs are third party.
I am a php developer with a few web apps like a project management app and a forum i'd like to move to Android and iPhone.
I've heard of developers using Sencha Touch and PhoneGap to develop native apps and I know they support HTML5, CSS and Javascript, but how abot PHP? And is are there any other APIs/frameworks I should consider that better support local server scripting?
Speaking about webapp, maybe you can avoid building an app by having a mobile enabled version of your website compliant with all the client browsers.
Have a look at jquerymobile, it is compliant with mostly all the mobile browsers and you will be able to reuse your code.
To answer correctly, you can call your webservices using ajax to fetch json/xml/etc data from Phonegap because it is using jQuerymobile ;-)
Have a look at this discussion here on Stackoverflow :
Passing formdata from Phonegap to PHP with JSON
Hope this helps
PHP is a server-side scripting language and your .php files have to be stored on the server side. You can access them asynchronously with Ajax, so no, you can not include php files (with reasonable time and effort) in your app.
The only smart way to go here is native iOS apps, forget PHP, Android and the rest of that crap. By the way I'm not trying to be an iOS snob here but am just reflecting on a few realities. One is that iOS apps can actually make money though a web replacement app might not. The second issue is that going native demands a reboot on your part, that is best done on one platform until you get up to speed. The third issue is that users now a days expect well performing apps that don't have a lot of web cruft in them. Fourth the Android marketplace is screwed, you are far more likely to establish that critical user base on iOS as you can target a handful of platforms running the latest generation of iOS, android is by comparison a pathetic mess of old versions of android running on all sorts of hardware.
On iOS look a BlueAlien as an example of a better than web method of accessing Reddit.