Created
December 9, 2014 13:40
-
-
Save albertmatyi/d021c669ce6722e93143 to your computer and use it in GitHub Desktop.
Share on facebook /w App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LOAD SDK | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId : 'your-app-id', | |
xfbml : true, | |
version : 'v2.2' | |
}); | |
}; | |
(function(d, s, id){ | |
var js, fjs = d.getElementsByTagName(s)[0]; | |
if (d.getElementById(id)) {return;} | |
js = d.createElement(s); js.id = id; | |
js.src = "//connect.facebook.net/en_US/sdk.js"; | |
fjs.parentNode.insertBefore(js, fjs); | |
}(document, 'script', 'facebook-jssdk')); | |
// Hasznalat | |
/** | |
* Regisztralom a sajat adatbazisomban a felhasznalot, hogy tudjam az emailcimet, meg hozzacsatolni majd a share adatot. | |
*/ | |
var registerUser = function (callback) { | |
// ez a Meteor frameworkbe van integralva szoval erre kell keressetek libraryt, vagy magatok implementaljatok | |
Meteor.loginWithFacebook({ | |
// engedelyt kell kerni facebooktol, hogy megkapjatok az email cimet az embernek (ehhez kell legyen az oldalnak egy privacy policy) | |
requestPermissions:['email'] | |
}, function () { | |
// kesz a login | |
callback(); | |
}); | |
}; | |
/** | |
* Post shareles | |
*/ | |
var sharePost = function () { | |
// meg 1x biztosodjunk meg rola, hogy a login sikeres volt | |
FB.getLoginStatus(function(response) { | |
if (response.status === 'connected') { | |
// nyissunk meg 1 kis fb popupot es shareljuk meg az object.html oldalt | |
FB.ui({ | |
method: 'share', | |
display: 'iframe', | |
href: 'http://some.web.site.ro/object.html', | |
}, function(response){ | |
if (response.error_code) { | |
// valami baj volt a sharrel | |
alert('Ej ej, te kis ravasz, nyar volt nem tavaz. Azt mondtad hogy szedunk ibolyat. Loooof...'); | |
} else { | |
var id = response.e2e; | |
$.post(/*... mentsetek el az id-t es az emailjet a loginelt csavonok */); | |
} | |
}); | |
} | |
}); | |
}; | |
// more/same info@ https://developers.facebook.com/docs/javascript/quickstart/v2.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- Facebooknak adatok a sharelt object.html -ben --> | |
<meta property="og:type" content="website" /> | |
<meta property="og:url" content="http://ennek.a.filenak.a.cime.ro/object.html" /> | |
<meta property="og:image" content="http://milyen.kep.jelenjen.meg.ro/kep.jpg" /> | |
<meta property="og:title" content="Az oldal cime" /> | |
<meta property="og:site_name" content="A website/app neve" /> | |
<meta property="og:description" content="Elmeseled hogy mit ettel reggelire" /> | |
<!-- stuff shmuff --> | |
</head> | |
<body> | |
<!-- moar stuff shmuff --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment