c# - ASP.NET & Facebook Connect - How To Post To User's Wall Using Graph API? -


i've integrated website facebook connect, authorization/single-sign on working great.

now im trying post user's wall, im having problems with.

first of all, im using "old" javascript api (featureloader.js).

these graph api url's im using:

private const string userdetails_url = @"https://graph.facebook.com/{0}?access_token={1}"; private const string feed_url = @"https://graph.facebook.com/{0}/feed?access_token={1}"; private const string tokenexchange_url = @"https://graph.facebook.com/oauth/access_token?{0}"; 

i'm using tokenexchange_url url receive unique user oauth token make calls with.

this working fine, because a) receive token back, , b) can issue http requests graph api (i.e userdetails_url) , works fine.

but, cannot post user's wall using feed_url.

i'm pretty sure issue haven't got appropriate user permissions post wall (i.e facebook-side setting).

now, realise can use fbpublish api method client-side this, want server-side graph api.

i wont bother showing code attempts call graph api post user's wall, pretty straightforward (httpwebrequest, set method "post', set content type/length, write bytes stream, etc).

i think problem need user grant aplpication "publish_stream" extended permissions.

the facebook graph api doco says in authorization request:

https://graph.facebook.com/oauth/authorize?     client_id=...&     redirect_uri=http://www.example.com/callback&     scope=user_photos,user_videos,publish_stream 

which confuses me because im using following url oauth token:

https://graph.facebook.com/oauth/access_token?bunchofqsparams 

am using wrong token exchange url? why there 2 different url's seemingly same piece of information?

yes - have read facebook api doco (numerous times), , yes have read other similar questions, result in using client-side api publish wall, want server side.

for actual "facebook connect" button, i'm using standard fbml:

<fb:login-button length="long" size="medium" autologoutlink="false" background="light" onlogin="facebooklogin('/login')" class=" fb_login_not_logged_in fb_login_button fb_elementready"><a id="res_id_fb_login" class="fbconnect_login_button"><img id="res_id_fb_login_image" src="http://static.ak.fbcdn.net/rsrc.php/zb6n8/hash/4li2k73z.gif" alt="connect"></a></fb:login-button> 

when click (and not logged facebook), pops window user can login. doesnt have "request extended permissions" dialog - shouldnt it? or popup need manually trigger?

so sum up, here questions:

  • how grant extended permissions publish user's wall?
  • what correct url obtaining oauth token?
  • is there definitive source showing how post user's wall using server-side graph api calls?

as presumed, missing call client-side api request extended permissions. (ie publish_stream).

i had simple javascript function executed part of "onlogin" attribute of fbml login control.

previously, doing redirect (which single-sign-on in server-side code).

now, im doing this:

function postlogin(targeturl) {    fb.facebook.apiclient.users_hasapppermission('publish_stream', function(result) {         if (result == 0 || result == null) {             fb.connect.showpermissiondialog('publish_stream', function() { redirectto(targeturl); });         } else {             redirectto(targeturl);         }     }); } 

translated english:

// on "facebook connect" click (which passes in redirect url) // check if user has 'publish-stream' permissions // if do, redirect. // if dont, show dialog requesting permission, redirect. 

now server-side graph api calls work fine.

so answer own original 3 questions:

  • how grant extended permissions publish user's wall?

answer: make use of client-side javascript api function 'fb.connect.showpermissiondialog' show popup, , 'fb.facebook.apliclient.users_hasapppermission' check if have permission.

  • what correct url obtaining oauth token?

answer: still believe "https://graph.facebook.com/oauth/access_token?{0}", "https://graph.facebook.com/oauth/authorize?{0}" might able used server-side authentication/authorization process.

  • is there definitive source showing how post user's wall using server-side graph api calls?

answer: if there was, wouldnt have had asked question - answer in short, no. =)

advice starting facebook connect work, try avoid "old javascript api". as can server-side (graph api), , use client-side javascript api initial handshake (cross domain receiver).


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -