c# - Links posted on Facebook page do not show up -
i working on little module needs automatically post links on facebook page. have done next setup:
created facebook page (the 1 display links) created facebook app added app both on page administrator profile on facebook page next permissions: publish_stream, manage_pagesin order obtain valid access token (manually - know not recommended, job in case) have done following:
logged in page administrator navigate page: https: / / developers.facebook.com/tools/access_token/ copy user token , create non-transient get-ting next url: https: / / graph.facebook.com/oauth/access_token?client_id={app id}&client_secret={app secret}&grant_type=fb_exchange_token&fb_exchange_token={the token copied earlier} get page access token user token resulted step 3 firing to: https://graph.facebook.com/me/accounts?access_token={the never expire access token}from json after step 4 re-create access token of page interested in , post link next c# code:
try { dynamic info = new expandoobject(); var fbm = message facebookmessage; data.access_token = connectiondata.authenticationtoken; data.message = fbm.message; data.link = fbm.link; data.name = fbm.name; data.caption = fbm.caption; data.description = fbm.description; if (!string.isnullorempty(fbm.icon)) { data.picture = fbm.icon; } var @params = ((expandoobject)data).tourl(); var _currentrequest = (system.net.httpwebrequest)system.net.webrequest.create(string.format("https://graph.facebook.com/{0}/feed?{1}", _currentendpoint.objectid, @params)); _currentrequest.method = "post"; _currentrequest.contenttype = "application/json; charset=utf-8"; _currentrequest.useragent = "mozilla/4.0 (compatible; windows nt)"; _currentrequest.accept = "*/*"; _currentrequest.cookiecontainer = new cookiecontainer(); _currentrequest.keepalive = false; //_currentrequest.credentials = system.net.credentialcache.defaultcredentials; //using (var sw = new streamwriter(_currentrequest.getrequeststream(), encoding.utf8)) //{ // sw.write(json); //} string json; var resp = _currentrequest.getresponse(); using (streamreader sr = new streamreader(resp.getresponsestream())) { json = sr.readtoend(); } var jsonserializer = new system.web.script.serialization.javascriptserializer(); var output = jsonserializer.deserialize<dynamic>(json); homecoming new operationstatus(); } grab (exception ex) { homecoming new operationstatus { exception = ex }; } }
the "_currentendpoint.objectid" object id of page. post done successful, , see link beingness posted both on administrator's wall on page long logged in admin. sooner log out, can't see posted links nor else liked page.
what gives? how can create links show on page wall , on walls of people liked page. did check spam on page, , don't see links there, , privacy settings seems visible.
after reading post: posting link page not showing up? got , running. problem seem have been access token, still haven't figured out went wrong: here did in end:
went graph api explorer http://developers.facebook.com/tools/explorer/ fired me/accounts as response got list of available accounts (including 1 app) took access token response.that seem have provided me access token needed post visible links on page wall.
c# facebook-graph-api hyperlink posting
No comments:
Post a Comment