Facebook Javascript fb.ui event to post photo on friends wall? - javascript

I want to create a button, when clicked, should open a Facebook dialog requesting user to post a photo (I mean a photo. Not a attachment link) on their friends wall.
Is that possible?
Actually this might remove the possibility of asking permissions for publish_stream as user will have entire control over what to publish and what not..

I'm almost sure it's not supported to post to another user's /photos connection -
When you retrieve the post ID you get, are you sure it's not appearing in your own profile / your own activity log?
{edit} there is no dialog which simulates the 'upload a photo to a friend's profile' functionality of facebook.com {/edit}

#Surya: You need the user's permission to post photos on his wall, and for that you need his permission to access his photos, which is achieved by the "publish_stream" parameter in your request. As far as your question is concerned, posting photos on your friends wall doesn't seem to possible. Even if it is possible it won't post it to your friend's wall unless he/she permits that. There is a way by which you can post the videos/photos but as a link and not as proper photos. Also I had noticed one more thing when I was trying to use photo sharing graph api, that it doesn't publish photos to your account immediately. It seeks the user's permission to be published, else the photos remain in his unpublished albums. You will find that album when you click on "Photos" section of your account. Check out my blog for more details :)
http://bashwithflash.blogspot.in/2012/05/photo-sharing-on-facebook-using-graph.html
http://bashwithflash.blogspot.in/2012/05/album-sharing-on-facebook-using-graph.html

Related

How to get response from FB page like in angular 5

I am using ngx-facebook for implement FB page like. I want to know if my FB page was liked or not to perform some action on basis of response.
I followed "https://www.npmjs.com/package/ngx-facebook" tutorial to implement FB like.
Rewarding users in any way for liking a Page is not allowed. The only way to know if a user liked a Page is to authorize that user with the user_likes permission. After that, you can check if the Page is liked. You will not get that permission approved by Facebook though, if you reward users for liking, or gate content behind likes.
TL;DR: It´s not possible and not allowed for your use case.
More information: https://developers.facebook.com/docs/apps/examples-platform-policy-4.4

Can I post a predefined message to a user's wall on Facebook?

I am creating a website page for a contest which involves users to post a specific message on their wall with a specific hashtag in order to be entered. I was looking through the JavaScript API for ways to post a preset message to their wall. I want to create a one click button, just like Twitter does, where you click a button, login and then click 'post' to post the message. Is there any way to do this?
I looked at some things but the publish stream is deprecated and no longer allows to specify a message.
I would really appreciate any advice. Thank you.
You should read https://developers.facebook.com/policy . Especially 2.3: "Ensure that all content in the user message parameter is entered by the user. Don’t pre-fill. This includes posts, messages, comments, and captions"

Facebook Graph API - Get profile picture prior to authenticating

Ok so i've tried the following:
FB.api("/me", {fields: "picture"}, function(response){
console.log(response);
});
And i'm trying to work around http://graph.facebook.com/USERNAME_OR_USERID/picture since obviously i don't know the users ID prior to authenticating.
All i want is a "modern" feel within the website, so i'd like to present the user with his or her's profile picture on the "login" div presenting the facebook login button. Is this possible? I know that Facebook and their graph api prohibits most such features but i would hope that a public profile picture would be accessible through the graph API..
I've Googled around and all the solutions say "use the USERNAME in the URL and you're fine" but i'm not, so to clear out any doubts, is this possible?
Error message: An active access token must be used to query information about the current user.
You can get everyone's Facebook profile picture without authentication.
You just call http://graph.facebook.com/USERNAME_OR_USERID/picture?type=large. This URL redirects you to image URL.
Type may be normal,small or large.
I also have questions for you:
How do you want to display the picture of someone without knowing who he/she is?
How can you guess which account the visitor will use to connect?
It looks like you want to know whose Facebook account was lastly connected on the browser of your visitor. Technically, you would want to read another site's cookies, which is 1) not allowed 2) impossible.
Several additional things you need to know:
http://graph.facebook.com/USERNAME_OR_USERID/picture is a public way to retrieve someone's photo. You don't need a token for that. What else do you need?
Using FB.API("/me", ...) from the JS SDK implies that "me" represents the connected user. It cannot just be used alone.
By the way, identical questions have already been answered and accepted:
Facebook app without prompted authentication
Get Facebook user's profile picture prior to authenticating app
Why would you hope the impossible?

Can we post photos on friends wall using Graph API

Is it possible to upload photos on friends wall? The documentation never mentioned that! but its happening. I am able to post to the /friend_id/photos connection.
I am actually running my app on local server using localhost tunneling. So, in August, I made an app where people can post photos on their friends wall (upon their request only). So, As I was pretty new to FB API, I didn't notice that it is not allowed.
I just left the app for few weeks and came back to fix things and I noticed that I am unable to post photos to the /friend_id/photos connection (Its just not working. I am not getting any errors). Its not even working for other possible connections like /friend_id/feed Is my app restricted to some graph actions?
So, I just created a test app and executed the same connection /friend_id/photos and **its working. Don't know why!**
This is not the end of surprise:
I successfully posted a photo on my friends wall using my test app
When I opened the photo, I could see its from "Surya's Photos" - my photos
I don't see that photo in my albums. I just don't know where its actually saved.
Update 2: This is indeed possible (is it a bug?) the same regular way.
But seems that posting of photo to other user's /photos connection behave very differently from posting to /me/photos. Here are some of the facts about posting to /FRIEND_ID/photos:
Every photo published that way creates separated album named Posting User's photos (that's it uploaded photos will never be grouped and there is no way to see all of them in single place).
That photo will not be visible in albums of either user or friend, but only will be seen/accessible via feed/timeline.
And for sure this is only working if you able to post on that friend's feed
So it really behaves just like any other content posted to friend's feed.
I would say if you not rely on album functionality and persistance of those photos and only want to "share" photo on friend's wall, go for it (unless it's proven to be bug).
TL;DR; No you cannot post photo to friend's /photos connection. Well, you can post photo to friend's /photos connection but it will not behave the same way if posted to your's /photos.
According to documentation of photos connection for user:
Create
You can post photos to a user's Wall on their behalf by issuing an HTTP POST request to PROFILE_ID/photos with the publish_stream permissions and the following parameters.
Also according to documentation of photo object:
https://graph.facebook.com/USER_ID/photos - The photo will be published to an album created for your app. We automatically create an album for your app if it does not already exist. All photos uploaded this way will then be added to this same album.
So generally speaking you trying to upload photo to other user's album but you may only post photos to your profile (or to page if using access_token for page).
You may however post to feed of other user (for example post may or may not have picture as attachement, which isn't the same as photo).
Update:
Photos may only be uploaded to /USER_ID/photos than USER_ID is the same as me (owner of access_token).
Is my app restricted to some graph actions?
There’s some places where FB say in the docs or developer blog posts, “If you misuse feature xy, your app’s ability to use it may be revoked” (not literally; I’m paraphrasing here, but something like that).
So it’s absolutely possible, that FB revoked the ability to post photos to friend’s walls specially for your app, because too many users receiving photos on their walls this way have marked them as “spam”.
(“Revoking a permission” is maybe not the exactly correct wording here; I think it’s more likely the Graph API accepts the requests made from your app in the first place, but then silently filters it out in the back; that would also explain why you not get any errors.)

how to get photos of facebook group, as uploaded by people other than group admins? (via JavaScript)

I'm building a website for a group that mirrors a facebook group, and I'd like to pull any photos of the group from facebook and display them on my site. BUT the photos might be uploaded by perfect strangers: so basically, a random person takes a picture of the group and uploads it to facebook, and we want that photo to be visible on our website.
I could think of three ways to do this:
tag the photo as the group and find all photos tagged as the group
It seems you can't get Graph API access to photos tagged as a particular group (please prove me wrong). I can do this in FQL: SELECT images FROM photo WHERE pid in (SELECT pid FROM photo_tag WHERE subject=GROUP_ID), but from what I can tell, this requires the website visitor to log into facebook to create a FB session, which is no good.
'share' the photo on our FB Page and somehow find all photos we've shared on our page
I can't seem to think of a way to restrict a search of shared objects to photos, but I'm open to suggestions.
re-upload the photo ourselves into a group-controlled photo album
meh. The first two options don't involve creating any new objects on facebook, and would be preferred, but I'm having a hard time doing either of them, which leaves me with downloading the photos from facebook and uploading them all over again in our own photo album, which I know how to show.
Please tell me there's a better way to do it than #3?
I've wrote a little PHP app which turned my Facebook news feed (/me/home) into RSS, and make it possible to subscribe by Google Reader. Although my project has nothing to do with publishing, I think you'll need some similar technique with the offline_access I've used there.
So, first of all, you'll need dummy Facebook user account which have the permission to read and publish in the group (since that's a public group so save you from some trouble)
Get the access_token of this user with "offline_access" and other scopes required for publishing like direct url example here http://developers.facebook.com/docs/reference/dialogs/oauth/
Then... hard code the access token into the PHP script
$access_token = the access token from oauth;
$facebook->setAccessToken($access_token);
Therefor, this script would act as that user. Anyone browsing the mirrored website doesn't even need a Facebook account.
After solving the authentication issue, the rest just simple coding for querying, uploading, publishing. Hope this would help

Categories