19677

Facebook push notification

Question:

Im using <a href="http://facebooksdk.net/" rel="nofollow">Facebook C# SDK</a> to post and fetch data. These simple tasks took forever to get running properly. Now I need to notify my webpage(ASP.NET C#) about changes on the specific facebook page so the webpage knows then it should fetch new data.

I have looked at this page : <a href="https://developers.facebook.com/docs/graph-api/real-time-updates/v2.2" rel="nofollow">https://developers.facebook.com/docs/graph-api/real-time-updates/v2.2</a>

But as usally with facebook documentations it misses to explain in detail how it works and how to get it working. Where exacly do I create the subscriptions? It says /{app-id}/subscriptions but I have tried this url with my app-id but no page is found?

I have tried to find examples on how to set this up but to no sucess.

Could someone please explain how this works? What do I need to do exacly to get this running?

Answer1:

Facebook subscription works by pinging a URL you own every time data has changed. You need to add a URL you own as a callback URL for Facebook subscriptions to work with

POST /v2.2/{app-id}/subscriptions HTTP/1.1 Host: graph.facebook.com object=page callback_url=http%3A%2F%2Fexample.com%2Fcallback%2F fields=feed verify_token=thisisaverifystring

In the above API request a POST request is made to add http://example.com/callback/ as the callback URL subscribing to the feed edges of the page object (a page object that the session user owns)

In your callback URL you must have it handle two actions

<ul><li>the initial callback (Handling Verification Requests via the verify token)</li> <li>saving updated subscriptions (Receiving the Real Time Updates)</li> </ul>

Here is an example of what it looks like in PHP

<?php if ($_REQUEST['hub_verify_token'] === 'thisisaverifystring') { echo $_REQUEST['hub_challenge']; } $file = 'sample.txt'; $inputJSON = json_decode(file_get_contents('php://input')); file_put_contents($file, file_get_contents('php://input') ); ?>

Recommend

  • WMQ Pub/Sub Topic to Queue bridge
  • linear predictor - ordered probit (ordinal, clm)
  • How to use QML - QWebView in Android
  • How to implement 'category' based newsletter
  • Validating embedded document in Mongoid based on embedded attribute
  • Read and Write DOCX file
  • How to list all the bucket types in riak?
  • How to detect if user cancel auto-renewable subscriptions during the free trial period?
  • youtube analytics api rows empty
  • Angular/Ionic 2 - what is a provider and what does `static get parameters()` do?
  • How to enumerate Azure subscriptions and tenants programmatically?
  • ASP.NET 5: Error with Nuget package in Class library Package
  • PHP mail() function not delivering mail
  • 403 forbidden error while sending messages to facebook connector through Unification Engine API
  • Selenium c#: WaitForCondition (how to find when ajax page is fully loaded)
  • Android Oreo JobIntentService Keep running in background for Android 7 &below and crashing often
  • Transpose table then set and rename index
  • ConfigurationBuilder not working in azure function
  • Unable to play media with vlc ocx
  • android google indoor map
  • req.body is undefined - nodejs
  • How to recover from a Spring Social ExpiredAuthorizationException
  • ILMerge & Keep Assembly Name
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Symfony2: How to get request parameter
  • Large data - storage and query
  • Akka Routing: Reply's send to router ends up as dead letters
  • WOWZA + RTMP + HTML5 Playback?
  • Is there a mandatory requirement to switch app.yaml?
  • Comma separated Values
  • Matrix multiplication with MKL
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • How to stop GridView from loading again when I press back button?
  • File not found error Google Drive API
  • Converting MP3 duration time