简体   繁体   中英

Facebook Open Graph Object Link to Facebook App

I'm building a Facebook canvas app which makes use of Open Graph. So for example the app pulls in content from http://www.mysite.com/ Say the action posted to the timeline as "Duncan completed MyObject on My App "

Clicking My App opens the app page on Facebook. However clicking the MyObject link opens the actual page where all my meta data is added outside of Facebook www.mysite.com

I really just want both links to open the app in Facebook. Am I missing a trick here or is my only solution to perform a redirect or something?

I understand I need to get Facebook to parse mysite.com in order to grab meta data. However, setting the og:url to the url of my app doesn't make a difference.

I was having the same issue. I ended up making a separate .jsp file which writes all the og: tags in the page, and in the body it only contains:

<script>
    location.href = "<%=redirectUrl%>";
</script>

The redirectUrl variable is a String I calculate from the original requested URL, it is like "http://apps.facebook.com/xxxyyy?myParam=zzz". Of course it can be anything, and in PHP or whatever language you use.

When you post an action to Open Graph, use the page with the redirect as the object URL. Facebook will parse the og tags nicely, and when an actual browser reads the page, it will redirect the user to your Facebook app.

I had the same problem, not sure if I was missing something really obvious.

I had a PHP file that followed the example file from Facebook. But when clicking the object on the timeline story, I noticed the following GET parameter: fb_source=timeline_og

So to solve the redirecting issue, I put the following at the top of the file, just inside the PHP tags:

<?php
    if ($_GET['fb_source'] == 'timeline_og') {
        // clicked on link in timeline, so redirect to required URL
        header('Location: REDIRECT_URL_HERE');
    }

(Obviously, replace REDIRECT_URL_HERE with whatever URL you wish to redirect to.)

Hopefully someone will find this useful!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM