简体   繁体   中英

Facebook “Recent Activity” from Asp.Net application

I am developing a public website with a FaceBook login. Once the user has logged in to the facebook, i want to post my website's URL with thumbnail to his facebook newsfeed "Has read : URL"

I am new to facebook integration. How can i achieve this from my asp.net application ? Right now, i have added two iframes LIKE and Recent Activity. I am able to see the post that i liked. But how can i post the URL which is read by me ? Thanks.

Note : For testing purpose i have used www.yahoo.com in the iframe.

Below source code is taken from

http://www.abelski.com/courses/facebookplugins/abelski_facebook_plugins_page.html

<iframe src="http://www.facebook.com/plugins/activity.php?site=sg.news.yahoo.com&width=300&height=300&header=true&colorscheme=light&font=arial&recommendations=true" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:300px;" allowTransparency="true"></iframe>

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fsg.news.yahoo.com&layout=standard&show_faces=true&width=450&action=like&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

You are looking for an Open Graph Action specifically the news.read action for an article object. You will need to set up an application that integrates this.

Each of your pages will need to have the meta tags conforming to an article object as defined as

<html>
    <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# 
                  article: http://ogp.me/ns/article#">
     <meta property="fb:app_id"               content="YOUR_APP_ID"> 
     <meta property="og:type"                 content="article"> 
     <meta property="og:url"                  content="URL of this object">
     <meta property="og:site_name"            content="Name of site hosting article">
     <meta property="og:image"                content="URL to an image">
     <meta property="og:title"                content="Name of article">
     <meta property="og:description"          content="Description of object"> 
     <meta property="article:published_time"  content="DateTime"> 
     <meta property="article:modified_time"   content="DateTime"> 
     <meta property="article:expiration_time" content="DateTime">
     <meta property="article:author"          content="URL to Author object">
     <meta property="article:section"         content="Section of article">
     <meta property="article:tag"             content="Keyword">
    </head>
<body>
    <!-- main article body -->
</body>
</html>

And your action in JavaScript will need to be set up as

function postRead()
  {
      FB.api(
        '/me/news.reads',
        'post',
        { article: 'http://yoursite.com/articlepage.html' },
        function(response) {
           if (!response || response.error) {
              alert('Error occured');
           } else {
              alert('Read was successful! Action ID: ' + response.id);
           }
        });
  }

Read more at the Open Graph Tutorial

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