Facebook OG: Register achivement doesn't work - ios

I'm trying to register facebook open graph achivement, but It doens't work.
Get app access token like this:
https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=SECRET&grant_type=client_credentials
HTML page look like this:
<html>
<head>
<meta property="og:type" content="game.achievement"/>
<meta property="og:title" content="TITLE"/>
<meta property="og:description" content="DESCRIPTION"/>
<meta property="og:url" content="URL/testAchivement.html"/>
<meta property="og:image" content="URL_TO_IMAGE"/>
<meta property="game:points" content="10"/>
<meta property="fb:app_id" content="APP_ID"/>
<title>ACHIEVEMENT!</title>
</head>
<body>
</body>
</html>
I use this:
https://graph.facebook.com/APP_ID/achievements?achievement=MYSERVER/testAchivement.html&display_order=2&access_token=APP_ACCESS_TOKEN
and get this response:
{
"data": [
]
}
No errors when using facebook debug tool.
Please help , thanks!

Related

How to force a page break in HtmlRenderer.PdfSharp?

I'm using "HTML Renderer for PDF using PDFsharp" HtmlRenderer.PdfSharp (version 1.5.1-beta1). I'm trying to force a page break. But I can't get this to work. What I have now in my html is this:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Test</title>
<style>
div { page-break-inside: auto; }
</style>
</head>
<body style="margin:0; padding:0;" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div>Page1</div>
<div>Page2</div>
</body>
</html>
Both div stay on the same page when I convert this html to PDF.
string contents = File.ReadAllText(#"C:\temp\test.html");
PdfDocument pdf = PdfGenerator.GeneratePdf(contents, PageSize.A4);
pdf.Save(#"C:\temp\pdfsharp.pdf");
How can I force the second div to a new page?
The only known solution to force page breaks is to split the html into parts, and generate a page for each html part. Solution from Grasher134 on GitHub: https://github.com/ArthurHub/HTML-Renderer/issues/49#issuecomment-251351431

Open Graph meta tags not accessible, preview of page in Facebook shows "422"?

I can't make my open graph tags accessible to Facebook. When I try to share a page, the site links properly, but the og attributes don't show up, and the title just displays as "422". I'm not sure what this means.
When I run the facebook debugger https://developers.facebook.com/tools/debug/og/object/ I get the following error, which isn't very helpful:
Error parsing input URL, no data was cached, or no data was scraped.
Using the echo feature in the debug tools, all I get is:
Document returned no data
The meta tags appear to be set up properly in my document:
<!DOCTYPE html>
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noarchive,noodp,noydir" />
<meta name="referrer" content="always" />
<meta property="fb:app_id" content="375576830972731" />
<meta property="og:site_name" content="Site Name" />
<meta property="og:title" content="Title of content" />
<meta property="og:url" content="https://website.domain.com/123456" />
<meta property="og:image" content="http://s3-us-west-1.amazonaws.com/domain/media/images/001/original/001" />
<meta property="og:description" content="Description of content" />
<meta property="og:type" content="article" />
</head>
I made sure to allow for the Facebook crawlers in robots.txt:
User-agent: Facebot
Allow: /
User-agent: facebookexternalhit/1.1
Allow: /
What I am I missing?
The problem here was my protect_from_forgerymethod in application.rb. I added an exception and the Facebot can now see the page.
class StoriesController < ApplicationController
protect_from_forgery except: :show

How to downcase an entire HTML document parsed with Nokogiri

I need to downcase all text in an HTML document that has been parsed with Nokogiri. Here my code:
agent = Mechanize.new
page = agent.get('http://www.example.com').parser.search('//*[translate(text(),"ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") = *]').to_html
There is not error as such in the code; it executes without an error. If I go in and check a random tag in the document, however, the case is still the same as before. Is there another/better way to downcase all text in a document?
You could use traverse to downcase all text nodes:
require 'open-uri'
require 'nokogiri'
doc = Nokogiri::HTML(open("http://www.example.com/"))
doc.traverse do |node|
node.content = node.content.downcase if node.text?
end
puts doc.to_html
Output:
<!DOCTYPE html>
<html>
<head>
<title>example domain</title>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
body { ... }
</style>
</head>
<body>
<div>
<h1>example domain</h1>
<p>this domain is established to be used for illustrative examples in documents. you may use this
domain in examples without prior coordination or asking for permission.</p>
<p>more information...</p>
</div>
</body>
</html>

grails header title not working with layout - sitemesh and layout

I have a base header layout (base-header-footer.gsp)
<!DOCTYPE html>
<html>
<head>
<title><g:layoutTitle default="${g.message(code: 'title.index.page')}"/></title>
</head>
... some common resources loading....
<body id="launch">
<g:layoutBody/>
...........................
<r:layoutResources />
</body>
</html>
And then 2 more header, one for logged-in user, and another for guest users, and both of these header layout are extending the base layout.
Guest users (anonymouys-header-footer.gsp) -
<g:applyLayout name="base-header-footer">
<!DOCTYPE html>
<html>
<head>
<g:layoutHead/>
</head>
<body>
... render guest user header
<g:layoutBody/>
</body>
</html>
Logged-in users (loggedin-header-footer.gsp) -
<g:applyLayout name="base-header-footer">
<!DOCTYPE html>
<html>
<head>
... some css
<g:layoutHead/>
</head>
<body>
... Render header for logged-in user
</body>
... load some JS file...
</html>
Now in specific pages I apply guest OR logged-in layout based on user's login state, hence I want to show the page specific title user is on, but it doesn't work.
This is how I am using those layout
OrderStatus.gsp -
<!DOCTYPE html>
<html>
<head>
<title>Order status | Some title</title>
<meta name="layout" content="logged-in-header-footer" />
<script type="text/javascript" src="${resource(dir:'js',file:'some.js')}"></script>
</head>
<body>
</body>
</html>
But I still see the title which is defined base-header-footer.gsp, not the one in OrderStatus.gsp
I have also tried using g:layoutTitle in OrderStatus.gsp but doesn't help.
Any help is highly appreciated.
Use
<meta name="layout" content="base-header-footer">
in your pages to load the layout, then add your title there,
<title>${whatever.something()}</title>
in your layout add this:
<title><g:layoutTitle/></title>
enjoy.
Try to use
<title><g:layoutTitle/></title>
in your layouts (base-header-footer and loggedin-header-footer.gsp). More info in the official documentation.

og meta Facebook & rails index: sharing info not updated in facebook share-box but correct in html

I'm using Facebook open graph meta tag inside one of my rails index view, which is an article post including a share on facebook link.
Everything worked well for the first post, and the facebook share box takes into account the meta provided (title, url, etc).
But when I want to share another post, then the facebook share-box keep the previous post info. In the html, the meta are good, and when I use facebook debug, everything is fine.
What I am missing ? There is a cache flush to do ?
Thank you a lot for the help
<meta property="og:title" content="<%= #post.title %> wanted on XXX!" />
<meta property="og:site_name" content= "Site Name" />
<meta property="og:url" content="http://siteroot<%= display_path(#post) %>" />
<meta property="og:description" content="Site is bla bla bla" />
<meta property="og:image" content="<%= #post.vignette.url(:medium) %>" />
<meta property="og:type" content="article" />
<meta property="article:publisher" content="https://www.facebook.com/appname" />
<meta property="article:section" content="Responsive" />
I can't tell if you're doing this or not but make sure you're sharing the post page and not the index page.
href="www.facebook.com/sharer/sharer.php?u=<%= #post.url %>"
The og tags in the head won't update without reloading the page, so you'll have to point Facebook to each post's unique url.

Resources