How to publish to a facebook wall as a different person - facebook

I maintain an asp.net website and have a requirement to publish to the businesses facebook wall as the business.
We set up a facebook app to do so.
So what happens is after a user clicks a button on the website the program calls facebook with scope=publish_stream,offline_access,manage_pages parameter
Facebook returns a code
We call facebook again with something that looks like this
string.Concat("https://graph.facebook.com/oauth/access_token?client_id=" + facebookPostClientId,
"&redirect_uri=" + "blah.aspx", "&client_secret=" + facebookPostSecret, "&code=" + code )
Facebook returns an access token.
We then call facebook to get all the accounts with something like this:
https://graph.facebook.com/" + facebook_user_id + "/accounts?access_token=" + accessToken;
We then loop throught the accounts until we find the correct one and call facebook again with something like
https://graph.facebook.com/" + userName + "/feed?&access_token=" + accessToken + "&picture=" + picture + "&name=" + "Studentcard - Deal" + "&link=" + link + "&message=" + message + "&caption=" + caption + "&from=" + userName + "&to=" + userName;
It works after a fashion. IF the owner of the business who created the facebook app is logged on to facebook, then the processing works.
If anyone else is logged on then it doesn't.
The reason being that the bit where we call facebook to get all th accounts only works when the business owner is logged on to facebook.
I tried inserting the business owners facebook id inbto the code instead off the logged on users, but it doesn't work.
So what do I do? Is this the wrong way to go about this?
I realise this maybe a bit long winded, but I am new to facebook and am providing as much information as I think necessary.
Thanks in advance
Niall

The reason being that the bit where we call facebook to get all th accounts only works when the business owner is logged on to facebook.
Separate this part of the process. Get all the accounts, and then cache them in your database. Whenever you fail to get the accounts, just use the cached information and proceed normally (otherwise update the DB and proceed normally).

Related

Facebook Graph API Image get URL Signature Expired

I use facebook API to Login in my project. But for long time, all user image in my project is broken image and get URL signature expired. Even though, I grab URL picture same in website facebook developer. And this is my code :
var profile_picture = "https://graph.facebook.com/" + response.id + "/picture";
Any solution for me ? because I really confused right now. Thank you very much.

Authenticate with Soundcloud without having to open a popup everytime

I'm having a lot of trouble with connecting to the spotify api on my mobile app.
I have been able to successfully able to get a token with this url:
"https://soundcloud.com/connect?client_id=" + client_id + "&response_type=token&redirect_uri=" + encodeURIComponent(redirect_uri) + "&state=" + Spotify.State + "&scope=" + encodeURIComponent(scope) + "&display=" + display;
However, this requires the user to click on connect every time they log into the app. Is there not a way to only have them authorize the app once?
I'm assuming that's what /oauth2/token is for, but when I change my &response_type=token to &response_type=code (above) so that I can pass the code into /oauth2/token it returns a redirect error (works fine with token).
I've looked around for samples but they are hard to come by. Any help would be greatly appreciated, even a point in the right direction.
I'm referring to the HTTP API guide (https://developers.soundcloud.com/docs/api/reference). I don't want to use a javascript plugin.

Facebook Graph API get USER token instead of APP token (phonegap)

I'm trying to implement facebook connect in Adobe PhoneGap through the Graph API but apparently I'm getting back an "App" token instead of a "User" token. This causes for my app to disallow any additional users connecting onto it, which is not the point of course.
I have notice this as no matter what user I use for logging in, the access_token returned is always the same.
I'm using the following URL to authenticate:
var authorize_url = "https://graph.facebook.com/oauth/authorize?";
authorize_url += "client_id=" + fb_clientid;
authorize_url += "&redirect_uri=" + fb_redirect_uri;
authorize_url += "&display=" + fb_display;
authorize_url += "&scope=publish_stream"
And to get the authorisation token:
https://graph.facebook.com/oauth/access_token?client_id='+fb_clientid+'&client_secret='+fb_secret+'&code='+fbCode+'&redirect_uri=http://www.facebook.com/connect/login_success.html'
I presume the problem lies with the second url (secret being passed indicates it's an app token) but then how do I get the user token?
Use the Facebook Connect plugin, instead of crafting the login procedure manually. It provides better usability as it is integrated with the Facebook native application or the iOS 6 Facebook functionality.

Trying to send facebook notification, results in "sorry, something went wrong" response

As from the title I am trying to use tha facebook notifications api. I have read the documentation and I am trying to do a POST to the graph like the one following:
String notificationURL =
"https://graph.facebook.com/" +
String.valueOf(facebookUserId) +
"/notifications?" +
"access_token=444146492324422|8LOOIj7xPT2LFlx14_3SqKCDgVc" +
"&href=https://apps.facebook.com/Nmctesting" +
"&template=#["+String.valueOf(facebookUserId)+"]! You have won!!";
the access token is the one returned from the graph query :
String appAccessURL = "https://graph.facebook.com/oauth/access_token?client_id=444146492324422"+
"&client_secret=[MYAPPSECRET]" +
"&grant_type=client_credentials";
I have tried to use the access token of the logged in user, who was the admin at that time, but It didn't work.
For any test that I do I get the html page as a response which states "Sorry, something went wrong"
what did went wrong?!
Thanks in advance!
Make sure your FACEBOOK_USER_ID is a valid facebook username. You may need to URI escape it first. If it's the correct username, https://www.facebook.com/FACEBOOK_USER_ID will be the user's facebook page, so try hitting it in a browser before you try anything else.

What's the mobileish connect url of Facebook connect?

I use the following URL setting to authorize Facebook login. But the page for Application Authorization is webish, and not mobileish.
webview
.loadUrl("http://www.connect.facebook.com/login.php?return_session=1&nochrome=1&fbconnect=1&extern=2&connect_display=popup&api_key="
+ FConnect.API_KEY
+ "&v=1.0&next="
+ FConnect.SUCCESS_URL
+ "%3Ffb_login%26fname%3D_opener&cancel_url="
+ FConnect.CANCEL_URL
+ "%23fname%3D_opener%26%257B%2522t%2522%253A3%252C%2522h%2522%253A%2522fbCancelLogin%2522%252C%2522sid%2522%253A%25220.741%2522%257D&channel_url="
+ FConnect.XD_RECEIVER);
As you see this is webish, as I had to scroll to the middle,
alt text http://img100.imageshack.us/img100/2100/facebookconnect.png
Do you know the address to get a mobileish App authorization page?
According to the Facebook developer wiki, it says that you have to set your display parameter to "wap" if you're on the mobile.
I guess you would have to check if the user is on a mobile or a PC. If on a mobile, change the display parameter to "wap", else keep it to "pop-up".