Permalink
Browse files

Gave up on XHP, adding a OG post

  • Loading branch information...
1 parent c8dcfee commit 414702f63d72b7132582d7a44b8806ea5f3db600 Colm Doyle committed May 6, 2012
Showing with 137 additions and 27 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 css/screen.css
  3. +31 −2 functions.php
  4. +41 −24 index.php
  5. +0 −1 master_include.php
  6. +20 −0 objects/testing.php
  7. +19 −0 objects/testing_object.html
  8. +8 −0 page_tab.php
  9. +16 −0 scripts/main.js
View
@@ -1 +1,2 @@
config.php
+*.swp
View
@@ -0,0 +1 @@
+#signed_request { width:250px;}
View
@@ -29,6 +29,35 @@ function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
-function test($echo) {
- return $echo;
+function output_standard_head(
+ $og_title,
+ $og_type,
+ $og_url,
+ $og_image,
+ $og_site_name,
+ $fb_app_id) {
+ $output .= '<meta property="og:title" content="' . $og_title . '" />';
+ $output .= '<meta property="og:type" content="' . $og_type . '" />';
+ $output .= '<meta property="og:url" content="' . $og_url . '" />';
+ $output .= '<meta property="og:image" content="' . $og_image . '" />';
+ $output .= '<meta property="og:site_name" content="' . $og_site_name . '" />';
+ $output .= '<meta property="fb:app_id" content="' . $fb_app_id . '" />';
+
+ return $output;
+}
+
+function curl_call($url, $post = false) {
+
+ $ch = curl_init();
+
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_ENCODING , "gzip");
+ curl_setopt($ch, CURLOPT_POST, $post);
+
+ $payload = curl_exec($ch);
+
+ curl_close($ch);
+
+ return $payload;
}
View
@@ -5,32 +5,49 @@
$signed_request = $_REQUEST['signed_request'];
$parsed_request = parse_signed_request($signed_request, $config['AppSecret']);
-$html_signed_request = <h3>Signed Request</h3>;
-$html_signed_request .= <pre>{$signed_request}</pre>;
-
-$html_parsed_request = <h3>Parsed Signed Request</h3>;
-$request_info_table = <tbody />;
-
-foreach($parsed_request as $title => $value) {
- $request_info_table->appendChild(
- <tr>
- <td>
- {$title}
- </td>
- <td>
- {$value}
- </td>
- </tr>
- );
+
+$signed_request_array = '<ul>';
+foreach($parsed_request as $key => $value)
+{
+if($key == 'user') {
+$signed_request_array .= '<li> user </li>';
+$signed_request_array .= '<ul>';
+ foreach($value as $sub_key => $sub_array) {
+
+ $signed_request_array .= '<li>';
+ $signed_request_array .= $sub_key . ' = ' . $sub_array;
+ $signed_request_array .= '</li>';
+ }
+$signed_request_array .= '</ul>';
+ } else {
+ $signed_request_array .= '<li>';
+ $signed_request_array .= $key . ' = <span id="'.$key.'" >' . $value . "</span>";
+ }
+ $signed_request_array .= '</li>';
}
+$signed_request_array .= '</ul>';
+$head = '<head>';
+$head .= output_standard_head('Colm\'s Sandbox', 'website', 'http://colmd.fbdublin.com/colms-sandbox/index.php', 'https://fbcdn-photos-a.akamaihd.net/photos-ak-snc7/v85005/230/120999667956026/app_10_120999667956026_1011543027.gif', 'Colm\'s Sandbox', $config['AppId']);
+$head .= '<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>';
+$head .= '<script src="scripts/main.js"></script>';
+$head .= '<link rel="stylesheet" type="text/css" href="css/screen.css" />';
+$head .= '</head>';
+
+$signed_request_div .= '<div id="signed_request">';
+$signed_request_div .= $signed_request_array;
+$signed_request_div .= '</div>';
+
+$publish_action_div .= '<div id="publish_action">';
+$publish_action_div .= '<a href="#" id="publish_action_link">';
+$publish_action_div .= 'Publish Test Action';
+$publish_action_div .= '</a>';
+$publish_action_div .= '<div id="action_response"></div>';
+$publish_action_div .= '</div>';
-$html_parsed_request .=
- <table>
- {$request_info_table}
- </table>;
-$html = $html_signed_request;
-$html .= $html_parsed_request;
+$body .= $signed_request_div;
+$body .= $publish_action_div;
-echo $html;
+echo $head;
+echo $body;
View
@@ -1,6 +1,5 @@
<?php
include('config.php');
-require_once('../xhp/init.php');
include('functions.php');
View
@@ -0,0 +1,20 @@
+<?php
+
+$fb_ref = $_REQUEST['fb_source'];
+
+?>
+
+<html>
+ <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# video: http://ogp.me/ns/video#">
+ <meta property="fb:app_id" content="120999667956026" />
+ <meta property="og:type" content="colms-sandbox:testing_object" />
+ <meta property="og:url" content="http://colmd.fbdublin.com/testing/testing.html" />
+ <meta property="og:title" content="Open Graph" />
+ <meta property="og:image" content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
+</head>
+<body>
+<p>Hello intrepid visitor.</p>
+<p> You appear to have come from <?php echo $fb_ref;?>
+</body>
+
+</html>
@@ -0,0 +1,19 @@
+<html>
+
+ <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# video: http://ogp.me/ns/video#">
+ <meta property="fb:app_id" content="120999667956026" />
+ <meta property="og:type" content="colms-sandbox:testing_object" />
+ <meta property="og:url" content="http://colmd.fbdublin.com/testing/testing.html" />
+ <meta property="og:title" content="Sample Testing Object" />
+ <meta property="og:image" content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
+ <meta property="colms-sandbox:dfdf:url" content="http://colmd.fbdublin.com/testing/video.html" />
+ <meta property="colms-sandbox:dfdf:secure_url" content="https://colmd.fbdublin.com/testing/video.html" />
+ <meta property="colms-sandbox:dfdf:type" content="iframe" />
+ <meta property="colms-sandbox:dfdf:width" content="500" />
+ <meta property="colms-sandbox:dfdf:height" content="500" />
+</head>
+<body>
+hello world
+</body>
+
+</html>
View
@@ -0,0 +1,8 @@
+<?php
+
+include('master_include.php');
+
+$signed_request = parse_signed_request($_REQUEST['signed_request'], $config['AppSecret']);
+echo('<pre>');
+print_r($signed_request);
+echo('</pre>');
View
@@ -0,0 +1,16 @@
+$(document).ready(function() {
+
+ $('#publish_action_link').click(function() {
+ var access_token_var = $('#oauth_token').text();
+ $.post("https://graph.facebook.com/me/colms-sandbox:test",
+ {
+ access_token: access_token_var,
+ testing_object: "http://colmd.fbdublin.com/colms-sandbox/objects/testing.php"
+ },
+ function(data) {
+ console.log(data);
+ $("#action_response").text(data);
+ });
+ });
+
+});

0 comments on commit 414702f

Please sign in to comment.