I am able to like Facebook pages using FBSDKLikeControl with that page url. Some thing like this.
let likeButton = FBSDKLikeControl()
likeButton.objectID = "https://www.facebook.com/FacebookDevelopers"
likeButton.center = self.view.center;
view.addSubview(likeButton)
However I am not able to do like on posts by giving likeButton.objectID = "1802945816386201_17414239392050"
Can we like user posts, photo using Facebook API ?
Related
I need some help with the 'invite friends' functionality of facebook.
The code I am using to invite friends is:
let inviteDialog:FBSDKAppInviteDialog = FBSDKAppInviteDialog()
if(inviteDialog.canShow()){
let appLinkUrl:NSURL = NSURL(string: "https://fb.me/9999999999")!
let previewImageUrl:NSURL = NSURL(string: "http://example.com/myimage.png")!
let inviteContent:FBSDKAppInviteContent = FBSDKAppInviteContent(appLinkURL: appLinkUrl)
inviteContent.previewImageURL = previewImageUrl
inviteDialog.content = inviteContent
inviteDialog.delegate = self
inviteDialog.show()
}
When I do the test in my iPhone, It redirect me to the facebook app and list my friends, then I choose some of then, send the invitation and get the following result in the logs.
[didComplete: 1]
But my friends does not get the notification.
I am the administrator in the facebook console, one of the invite friends is in the developer role and the other one is in the tester role.
I created the appLink with facebook.
The configuration in my facebook console is:
Thanks!
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'm using Django-social-auth for facebook login and Facepy to retrieve data from facebook.
Now I'm trying to get the list of all the pages liked by a user's friend. If I use:
graph.get('some_friend_id/likes')
I get an empty list of likes ( {'data': []} ).
I have added 'friends_likes' on my facebook app's User & Friend Permissions, and still it doesn't work.
my code looks like this:
instance = UserSocialAuth.objects.filter(user=request.user).filter(provider='facebook')
graph = GraphAPI(instance[0].extra_data['access_token'])
ps = graph.get('me/friends')
myfriends = ps['data']
frnd_id = myfriends[29]['id'] # getting a friend's ID
lk = frnd_id + '/likes'
frnd_likes = graph.get(lk)
print frnd_likes
A little help would be great. Thanks!
I developed a application in facebook, and it can be automatically to post something on the users' wall. But now I want to post only once per day, how can I do it?
When you do call api to publish something on his/her wall, also save it into DB and then check it before each API call
<?php
$uid = $facebook->getUID();
$publishes = mysql_query("SELECT * FROM publishes WHERE uid = ".$uid." AND time > ".(time()-60*60*24);
$publish = mysql_fetch_assoc($publishes);
if (!$publish['time'])
{
//call api and post a post to a wall
}
My requirement was to update members status from my site, i am also thinking about displaying their friends photos and their last status update.
I have looked all over the docs and cant decide which works for my need. RESTful API, JavaScript API, FQL, XFBML, FBML, FBJS ?? whcin one works best? or best way?
It should be like, when they first go to the page,there will be nothing but a login option. when they click on it, a pop up should appear and when they are authorized, we display a text area to post update. Here, i wanted to show their friends pics too
when they came back later, they should able to post right away, must not ask for login again.
Can some one help me with the code?? I dont expect you to write everything, get the friends pic and their last update into a PHP array would be nice.
Many thanks
If u need to update users data stored at ur database so u will use the facebook API to check user signed in and get his data. i have an ifram application at facebook and i am using C# code (asp.net application) and when the user request the application i authenticate that he is signed in to facebook and check if he is already exist in my database? if not so i get his information(by using facebook API) and add the user in my data base and each time he visits the application i update his information.
With respect to his friends i get all facebook ids of the user friends and then loop these IDs and get the pic of each ID.
Download Facebook Developer Toolkit that enables u communicate with facebook and use facebook API to get user information.
hope that is will help u
Visit my application in facebook and u will see these features at the following link :
http://apps.facebook.com/hanggame/
Getting the session Key :
protected void Page_Load(object sender, EventArgs e)
{
//Facebook code for integration with facebook users:
_fbService.ApplicationKey = "Application Key";
_fbService.Secret = "Secret Key";
_fbService.IsDesktopApplication = false;
string sessionKey = (string)Session["Facebook_session_key"];
if (Session["Facebook_userId"] != null)
userId = (long)Session["Facebook_userId"];
// When the user uses the Facebook login page, the redirect back here will will have the auth_token in the query params
string authToken = Request.QueryString["auth_token"];
if (!String.IsNullOrEmpty(sessionKey))
{
_fbService.SessionKey = sessionKey;
_fbService.uid = userId;
}
else if (!String.IsNullOrEmpty(authToken))
{
_fbService.CreateSession(authToken);
Session["Facebook_session_key"] = _fbService.SessionKey;
Session["Facebook_userId"] = _fbService.uid;
Session["Facebook_session_expires"] = _fbService.SessionExpires;
}
else
{
Response.Redirect(#"http://www.Facebook.com/login.php?api_key=" + _fbService.ApplicationKey + #"&v=1.0");
}
userId = _fbService.uid;
//End of Facebook code
}