Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Registration Tool Tutorial

  • Loading branch information...
commit 89ae2ff60a25e9f9ae3892032dba2837aa380677 1 parent e38922b
@mschakulat authored
View
31 user-registration/custom-fields.php
@@ -0,0 +1,31 @@
+<?php
+$json = '[
+ {"name":"name"},
+ {"name":"email"},
+ {"name":"location"},
+ {"name":"gender"},
+ {"name":"birthday"},
+ {"name":"password", "view":"not_prefilled"},
+ {"name":"like", "description":"Gefällt Dir dieses Plugin?", "type":"checkbox", "default":"checked"},
+ {"name":"phone", "description":"Telefonnummer", "type":"text"},
+ {"name":"anniversary","description":"Jahrestag", "type":"date"},
+ {"name":"useplugin", "description":"Wirst Du dieses Plugin einsetzen?", "type":"select", "options":{"ja":"Ja","nein":"Nein"}, "default":"ja"},
+ {"name":"movie", "description":"Lieblingsfilm", "type":"typeahead", "categories":["movie","book"]},
+ {"name":"captcha"}
+]
+';
+?>
+
+<div style="width: 560px; margin: 0 auto;">
+ <iframe src='http://www.facebook.com/plugins/registration.php?
+ client_id=140311802689086&
+ redirect_uri=http://user-registration.abouttheweb.de/&
+ fields=<?= $json ?>'
+ scrolling="auto"
+ frameborder="no"
+ style="border:none"
+ allowTransparency="true"
+ width="100%"
+ height="700">
+ </iframe>
+</div>
View
68 user-registration/index.php
@@ -0,0 +1,68 @@
+<?php
+define('FACEBOOK_APP_ID', '140311802689086');
+define('FACEBOOK_SECRET', '5beff86f67ef26fdebed3b4e7be886b7');
+
+function parse_signed_request($signed_request, $secret) {
+ list($encoded_sig, $payload) = explode('.', $signed_request, 2);
+
+ // decode the data
+ $sig = base64_url_decode($encoded_sig);
+ $data = json_decode(base64_url_decode($payload), true);
+
+ if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
+ error_log('Unknown algorithm. Expected HMAC-SHA256');
+ return null;
+ }
+
+ // check sig
+ $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
+ if ($sig !== $expected_sig) {
+ error_log('Bad Signed JSON signature!');
+ return null;
+ }
+
+ return $data;
+}
+
+function base64_url_decode($input) {
+ return base64_decode(strtr($input, '-_', '+/'));
+}
+
+$json = '[
+ {"name":"name"},
+ {"name":"email"},
+ {"name":"location"},
+ {"name":"gender"},
+ {"name":"birthday"},
+ {"name":"password", "view":"not_prefilled"},
+ {"name":"like", "description":"Gefällt Dir dieses Plugin?", "type":"checkbox", "default":"checked"},
+ {"name":"phone", "description":"Telefonnummer", "type":"text"},
+ {"name":"anniversary","description":"Jahrestag", "type":"date"},
+ {"name":"useplugin", "description":"Wirst Du dieses Plugin einsetzen?", "type":"select", "options":{"ja":"Ja","nein":"Nein"}, "default":"ja"},
+ {"name":"movie", "description":"Lieblingsfilm", "type":"typeahead", "categories":["movie","book"]},
+ {"name":"captcha"}
+]
+';
+?>
+
+<?php if ($_REQUEST['signed_request']) : ?>
+ <?php
+ print '<p>signed_request contents:</p>';
+ $response = parse_signed_request($_REQUEST['signed_request'], FACEBOOK_SECRET);
+ print '<pre>' . print_r($response, true) . '</pre>';
+ ?>
+<?php else : ?>
+<div style="width: 560px; margin: 0 auto;">
+ <iframe src='http://www.facebook.com/plugins/registration.php?
+ client_id=140311802689086&
+ redirect_uri=http://user-registration.abouttheweb.de/&
+ fields=<?= $json ?>'
+ scrolling="auto"
+ frameborder="no"
+ style="border:none"
+ allowTransparency="true"
+ width="100%"
+ height="700">
+ </iframe>
+</div>
+<?php endif ?>
View
13 user-registration/named-fields.php
@@ -0,0 +1,13 @@
+<div style="width: 560px; margin: 0 auto;">
+ <iframe src="http://www.facebook.com/plugins/registration.php?
+ client_id=140311802689086&
+ redirect_uri=http://user-registration.abouttheweb.de/&
+ fields=name,first_name,last_name,birthday,email,gender,location,password,captcha"
+ scrolling="auto"
+ frameborder="no"
+ style="border:none"
+ allowTransparency="true"
+ width="100%"
+ height="700">
+ </iframe>
+</div>
View
12 user-registration/simple.php
@@ -0,0 +1,12 @@
+<div style="width: 560px; margin: 0 auto;">
+ <iframe src="http://www.facebook.com/plugins/registration.php?
+ client_id=140311802689086&
+ redirect_uri=http://user-registration.abouttheweb.de/"
+ scrolling="auto"
+ frameborder="no"
+ style="border:none"
+ allowTransparency="true"
+ width="100%"
+ height="500">
+ </iframe>
+</div>
View
8 user-registration/xfbml.php
@@ -0,0 +1,8 @@
+<div id="fb-root"></div>
+<script src="http://connect.facebook.net/de_DE/all.js#appId=140311802689086&xfbml=1"></script>
+
+<fb:registration
+ fields="name,birthday,gender,location,email"
+ redirect-uri="http://user-registration.abouttheweb.de/"
+ width=560>
+</fb:registration>
Please sign in to comment.
Something went wrong with that request. Please try again.