i little speak english
i want create feed (post, note, link) to page wall ANY TIME (like offline_access) with new graph api
What should I do for it , what permissions should
thank you in advance.
create facebook app
take appid
copy this link to browser
https://www.facebook.com/dialog/oauth?client_id=appid&redirect_uri=canvasurl&scope=manage_pages&response_type=token
provide appid and the url u given in canvas url(eg:http://localhost/web)
redirected url u can see access token.take that access token value.
Facebook_Graph_Toolkit.GraphApi.Api x = new Facebook_Graph_Toolkit.GraphApi.Api(accesstoken);
string id = x.PostFeedToTarget("pageid", "hi test");
Related
I have 3 questions: 1)Can I combine facebook login via mozila browser(selenium) with facebook graph api, for example:
browser=webdriver.Firefox()
browser.get('https://facebook.com')
user=browser.find_element_by_id('email')
user.send_keys('email')
password=browser.find_element_by_id('pass')
password.send_keys('pass')
login=browser.find_element_by_id('u_0_r')
login.click()
graph = facebook.GraphAPI(token)
profile = graph.get_object("me")
friends = graph.get_connections("me", "friends")
friend_list = [friend['name'] for friend in friends['data']]
print (friend_list)
2)Can somebody help me with login on facebook through app_id, secret_id and token, or through email and password
3)I want to get profile info, for example with help of get_object, but I need to know user's id to do it. How can I get this id, if I have only page url's, or I can use part after facebook.com/ to do this request?
P.s. If u know answer at least on one of this questions, pls right it in comments or in answers, it will be very useful:)
My problem is: When I post to page's wall some message with link it shows as Posted By Others, without link it shows normally in page timeline (Im group's admin ).
The same code posts to my timeline just fine:
I use AS3 library.
My permissions:
"publish_stream", "user_photos","publish_actions","manage_pages"
my post code:
var params:Object = new Object();
params.message = messageTextInput.text;
params.description = "description";
params.caption = "caption";
params.name = "name";
params.link = "http://www.ya.ru";
params.picture = "http://image.bayimg.com/cajchaado.jpg";
FacebookDesktop.api(page.id+"/feed", onCallApi, params, "POST"); //use POST to send data (as per Facebook documentation)
Facebook documentation says I can post either link or message, but it works just fine, except of showing in "Recent posts by others" ( please see attached screenshot ).
To post on a fanpage on behalf of itself (not the user), you have to use the page access token.
What happening is- when you make the call, the sdk uses the default token (user token), so the post is published on behalf of the user which is displayed in the "Recent Post by Others" section in the page.
Since you have requested for manage_pages already in your code, you can simply obtain the page access token with this call- /{page-id}?fields=access_token. Use this token with your current call just by adding the parameter access_token-
....
params.picture = "http://image.bayimg.com/cajchaado.jpg";
params.access_token = "{page-access-token}";
....
I am using RESTFb api to post a message on facebook wall
my code is:
val facebookClient: FacebookClient = new DefaultFacebookClient("access_key")
def publishMessage(msg:Mesage): String = {
val publishMessageResponse: FacebookType = facebookClient.publish("me/feed", classOf[FacebookType],
Parameter.`with`("message", msg))
publishMessageResponse.getId()
}
But this code is working only when I am login in my facebook account.If I am not login it give me the error of "user session logout". and it told me to generate the access token every time.
Thats because you are trying to post to your own Wall.. thats why, OAuth needs to validate you are logged otherwise it wont post anything... if you where posting to a PAGE... well that's diferent you could use APP and SECRET ID's to generate AccessTokens on your website.
As FaceBook launched a new concept of pages, I created a page, but I am not able to find any C# SDK for posting on that page's timeline from code.
First you need C# SDK
you can download from here
http://csharpsdk.org/
may be you need manage_page permission to get a page access token
you can get a page access token using this Graph Request http://developers.facebook.com/tools/explorer/?method=GET&path=me%2Faccounts
after getting page access token you can post a on page wall using this code
var fb = new Facebook.FacebookClient(PageAccessToken);
var postArgs = new Dictionary<string, string>();
postArgs["link"] = "http://www.foo.com";
postArgs["name"] = "Click Here To View";
postArgs["message"] = Message;
fb.Post("[pageid]/feed/", postArgs);
I'm trying to tag a user (having its userid), with a Graph request made to a picture just uploaded to a Page Gallery.
Permissions I use in the app are:
#"read_stream", #"offline_access", #"publish_stream", #"manage_pages",#"photo_upload",#"user_photos" and with a access_token to the session got from page_it?fields=access_token item (that works for picture upload in gallery).
And I use them to upload the photo to a Gallery on a Fan Page successfully.
When I try to tag the user with a graph request in the form:
POST to picture_id/tags with param: "to"->userid
I get only facebookErrDomain error 10000 as if permissions are not right.
From API Documentation seems that only user_photos and publish_stream are required and no mention to page-galleries photo is made.
I'm quite clueless about this issue.
It's possible. You need to collect the page's specific token by placing a call to /me/accounts. And then tag the photo using page's access token. Once you get that, you can tag the photo using it's Graph Object Id and user id whom you are tagging.
if (accessToken) {
var data = {
"access_token": accessToken,
to:userId,
x:x,
y:y
}
FB.api("/" + photoId+"/tags/"+userId , 'post', data, function(response) {
//here is the response
});
}
Hope it helps. The key is the access token that is specific to that page :)