Can an in-app object only be posted through an opengraph action? - facebook

I have a page inside a facebook application that is an opengraph object, when I post a custom action on this object to facebook from my app it is posted right, but when I use a facebook social plugin such as like and like that object it is not posted as that object but instead the object of my facebook application is posted on the timeline... so my question here is Can an in-app object only be posted through an opengraph action?

Nope, new OpenGraph object will be created or data will be updated for existing one once Facebook linter crawl your page to get data this will happen in several cases:
OpenGraph action referencing object published
Like button clicked for specific URL
Link to your page shared on Facebook (in direct way or via any dialogs using link, etc).
Your Like button is probably linked not to your real application URL but to URL within Facebook resulting in different Pages parsed by Facebook on Like Button click and OpenGraph action publishing.
I assume that your like button pointing to Application Tab Canvas or Application Page since links to regular application's canvas parsed correctly by Facebook.
Update:
Seems like the issue with OpenGraph tags is related to the fact that your application returning 404 (Not Found status code) for URL you provided and only returns data for HTTP (but not HTTPS) requests. If error code is returned the cached data is preserved and will not be updated until correct status code returned.
Update 2:
As you've provided real URL it's became clear that you get details for your application instead of actual page because of redirect for all unauthorized users, which lead to inability to rich the real OpenGraph data by Facebook linter.
BTW, You should be aware that every OpenGraph object MUST have publicly accessible URL.

Related

is it possible to share whole Fb app Canvas page through app?

I'm working on a photo contest fb app to run in a fan page tab. the user should be able to share the photo in order for others to vote for them.
supposing image link in iframe is http://example.com/image.php?id=1 for particular photo, pressing share will share this link through iframe. which leads up to the host app itself.
what I need is sharing the whole fb app tab page url with http://example.com/image.php?id=1 open in its Iframe.
is that possible in any way?
thanks for help.
So to give the “alternative” to #Lix’ answer, which focuses on canvas apps, here the analog way for page tab apps:
For some reason Facebook decided to do things differently for page tab apps – different than with canvas apps, you can not pass just any GET parameters to your app by appending them to the facebook.com address of your app, but you have to use the app_data parameter for that.
You call/link to your app in the form https://www.facebook.com/YourPage?v=app_1234567890&app_data=foo – and whatever you put as value for the parameter app_data, you will find in the signed_request parameter that Facebook POSTs to your app on initial(!) load into the iframe.
So you parse the signed_request (or let f.e. the PHP SDK do that for you), and then you find the app_data value in there. If you want to pass more than one single value, you can f.e. also put JSON-encoded data there – then you have to decode that again after you read the app_data value from the signed request.
The docs just shortly mention the app_data parameter, but the principle itself is quite simple.
Now, when it comes to sharing those links, I found that when you use an address in the above form, Facebook tends to cut the parameters from the URL, and treat the whole link as just a link to your Facebook page – it shows the page’s picture and description, and does not even pass your page tab app along, let alone the app_data parameter.
I found the most reliable way around this is not to link to your page tab on Facebook directly, but instead to a URL of your own app. When the scraper visits it, you deliver the relevant OG information. And when it’s a real user visiting, you redirect them to your page tab app, passing the data you need via the app_data parameter as described above. Redirecting can either be done server-side (info on how to detect the scraper server-side via its User-Agent header), or client-side via JavaScript (which the scraper does not “speak”).
Sure it is. All you have to do is be able to extract the information from your application canvas URL. If your canvas URL is something like this:
https://apps.facebook.com/ImadBakir
Then you could place some more info in there, like this:
https://apps.facebook.com/ImadBakir?photo_id=123
Users will share that link and now in your application, you can parse that photo_id parameter and make the needed HTML changes to display the correct image inside your iframe as the page and application loads.
With regard to parsing the the URL parameters, assuming you'll be doing it with JavaScript, you can read more about it in this post:
How can I get query string values in JavaScript?

Can't access ViewBag data in Facebook App

I have a Facebook app that is giving me fits. I basically have an app that once the user has liked the app, they can continue through the app. Using the Facebook Javascript API, it will see if the user has logged in, and if not allow them to log in. I pass rather or not they "like" the page from the controller, as well as their language (English or Spanish) to the view via the ViewBag object.
This works both locally and from the staging server; however I have to disable the like check in the view, but the language and like is passed in the viewbag.
I placed language in the view like
<p>The user's language is #ViewBag.lang</p>
and
<p>They like the page? #ViewBag.likes
Like I said, both locally and at the staging server it works; but nothing gets passed through to the Facebook app. I have a conditional check to see if the user likes the page in javascript like:
var likes = #ViewBag.likes
In Facebook, using the console I see that the data isn't passed as well as the before mentioned debugging I tried doing.
I am very new to MVC; is there something I need to enable to make it work through Facebook?
Thanks!
Well the issue is that the Facebook canvas sends an initial POST, this was hitting my POST instead of the GET which was setting these values. See here:
Does Facebook open a canvas app with a Post request? It's causing havoc with my MVC actions
Thanks!

Comments social plugin for Action post

I have an app app1 which defines a custom Facebook action act1.
When a user performs this action to an entity (ntt1) in my app, I post to API /me/app1:act1 with URL to ntt1 as its param, so that a post is generated on user's wall saying User act1'ed ntt1 where ntt1 is a link to ntt1's view page (with open graph meta data on its header).
Users can comment or like on this wall post regularly.
Now I want to show users' comments on ntt1's web page as well to share the comments and likes between the Facebook wall and ntt1's view page.
I tried using the Comments social plug-in, but don't know what to put in the data-href to point to the action_instance_id of the wall post.
I know I can simulate a comments box on my page using the graph API (and I've already done so), but this is not making a good ux, because the users need to authorize to my application to view this page (so that the java script API can fetch the comments from the Facebook).
Have you tried just pointing the data-href attribute to
https://www.facebook.com/{user_name_or_id}/activity/{action-instance-id}
…? The docs for using actions say this is the URL you can use to “preview” the news feed story that this published action will generate (or rather has already generated, because without publishing the action first, you would not have an action-instance-id).
If you click on the “x minutes/hours/… ago” link for the feed story for one of your published actions, it should take you to a link that’s build using the same scheme.

Why do app posts to Facebook not show as pasted via my app, despite OK OpenGraph response?

We have an app on Facebook called TouchActive
We provide ways for user to post content to Facebook, either from web (via AddThis) or native Android/iOS app.
When we post from say Android we identify the app and the post appears correctly, showing "... via TouchActive" all fine.
When we post from web, we post a URL that Facebook queries, and we provide an OpenGraph response from our server with all the og: meta tags, including the facebook app_id.
The content appears correctly (it's parsing the OG response OK), but it doesn't show as posted via our app, and the posts don't appear in our Insight statistics for the app.
We are assuming this can be done.
Anyone know what we could be doing wrong in our open graph response that causes this to not work?
I have tried the Facebook debug tool https://developers.facebook.com/tools/debug and it shows the correctly parsed OG response and no errors, only a warning about og:url.
Is og:url recommended or a MUST for this to work?
Andrew: I am also using the same meta tag for my site and it works as expected and the post is attributed to my site. I guess u should specify the og:url meta-tag once and then check. As this url is used on the attributed app's anchor link on fb wall.
If still it has the same issue then we can dig it more to come to solution.
A user manually sharing a link to or liking a web page which has opengraph meta tags (including an App ID) is not the same as posting the content from the app - are you definitely posting the links using the app?
You must post via the API to get the post attributed to your app, regardless of which app is specified on the page's meta tag (which is done primarily for insights and administration purposes)

Refresh meta data in posted URL

In Facebook, when I post the link http://wisdomuniversity.org, Fascebook includes old metadata (Title, description, etc.). I recently added Open Graph Protocol meta tags, but Facebook still uses the old stuff. How does Facebook refresh this metadata and can I force a refresh?
You need to ping facebook and notify them to update changes and to do that you can use
URL Linter. It may take some time for facebook to update your changes. I'm not sure how much time they take to update after pinging, but just try it.
EDIT: This is officially from facebook: Open Graph protocol
Editing Meta Tags
You can update the attributes of your page by updating your page's
tags. Note that og:title and og:type are only editable
initially - after your page receives 50 likes the title becomes fixed,
and after your page receives 10,000 likes the type becomes fixed.
These properties are fixed to avoid surprising users who have liked
the page already. Changing the title or type tags after these limits
are reached does nothing, your page retains the original title and
type.
For the changes to be reflected on Facebook, you must force your page
to be scraped. The page is scraped when an admin for the page clicks
the Like button or when the URL is entered into the Facebook URL
Linter. You can programmatically force your page to be scraped by
cURL'ing the linter. For example:
curl
> https://developers.facebook.com/tools/lint/?url={YOUR_URL}&format=json
Use Facebook debbugger and detect the problems related to og FB metadata, https://developers.facebook.com/tools/debug/. Then, if Fb says your image is too small, pull a bigger image and use odd width for the image e.g. 300px, 500px etc. It seems when FB doesn't find the correct image size, title or description, trends to grab main site metadata.
You can update your Open Graph object information but just sending a CURL request, like documented here: https://developers.facebook.com/docs/sharing/opengraph/using-objects
POST https://graph.facebook.com/?id={object-instance-id or object-url}&scrape=true
I hope this helps...
Tool URL has changed to https://developers.facebook.com/tools/debug. Now GET request should be sent to: https://developers.facebook.com/tools/debug/og/object?q={YOUR_URL}.
If you are getting an error "Error parsing input URL, no data was scraped." try to add following header to a request: Referrer: https://developers.facebook.com
As of the end of 2016, the way to programmatically notify Facebook of changes in your URL and have it scrape it again is by submitting a POST to this URL:
https://graph.facebook.com/?id={YOUR_URL}&scrape=true
Earlier ways, some noted on this page, have been deprecated. This is documented here:
The Facebook crawler will re-scrape (and therefore update) objects:
When the object URL is input in the Object Debugger Every 30 days
after the first scrape When an app triggers a scrape using an API
endpoint This Graph API endpoint is simply a call to:
POST /?id={object-instance-id or object-url}&scrape=true
The response from this endpoint will be a JSON object that contains all the
information about the object that was scraped (the same data returned
when the Object ID is read from the Graph API).
The id parameter can be either the canonical URL of your object or the
ID of the object instance in the graph.