How can I place a comment in Facebook Open Graph API post? - facebook-graph-api

I create posts using Facebook Open Graph API with custom action. These posts are displayed in Timeline with caption "User Name added a visit..." ("add" and "visit" are my custom action and object), then a block with image, title and description.
I create a post sending HTTP POST request to Facebook with only a link to page. Facebook fetches data from this page from meta tags og:type, og:url, og:title, og:image, og:description.
I want to place a text between caption "User Name added a visit..." and image. How can I do that?

Use 'message' parameter in your open graph call. The text in this key will be shown in the place where you want.

Related

A way to create the wall post when creating an album in a group with Facebook Graph API 2.10?

I used to do a POST /group-id/albums to create albums in a group. Then I would POST /album-id/comments to comment on the album. Then I would GET /group-id/feed?fields=comments, and find the id of my comment, and from that have the wall post id. You know, the post that says So and So added 3 photos to the album ...
Using the wall post id, I can delete the album, even though the Graph API does not allow deleting albums directly.
Starting today, the ability to post comments was removed through the API, except for page apps: https://developers.facebook.com/blog/post/2017/07/18/graph-api-v2.10/
Is there any way now, without commenting, to get the album story to the wall?
Here is a partial answer.
This parameter is not documented on the Group album, but it is on the User album. Set 'make_shared_album=true' in the post body. This will make a wall post for the creation of the album, and it looks like it shows up on your feed.
However, I cannot find a way to get that post_id. The post does not show up in the group's feed, oddly, though if you make a permalink to it, the permalink is part of the group. Sadly, the post_id is also not based on the album'd id, so there's no way to guess it.

Is it possible to read tweet-text of a tweet URL without twitter API?

I am using Goose to read the title/text-body of an article from a URL. However, this does not work with a twitter URL, I guess due to the different HTML tag structure. Is there a way to read the tweet text from such a link?
One such example of a tweet (shortened link) is as follows:
https://twitter.com/UniteAlbertans/status/899468829151043584/photo/1
NOTE: I know how to read Tweets through twitter API. However, I am not interested in that. I just want to get the text by parsing the HTML source without all the twitter authentication hassle.
Scrape yourself
Open the url of the tweet, pass to HTML parser of your choice and extract the XPaths you are interested in.
Scraping is discussed in: http://docs.python-guide.org/en/latest/scenarios/scrape/
XPaths can be obtained by right-clicking to element you want, selecting "Inspect", right clicking on the highlighted line in Inspector and selecting "Copy" > "Copy XPath" if the structure of the site is always the same. Otherwise choose properties that define exactly the object you want.
In your case:
//div[contains(#class, 'permalink-tweet-container')]//strong[contains(#class, 'fullname')]/text()
will get you the name of the author and
//div[contains(#class, 'permalink-tweet-container')]//p[contains(#class, 'tweet-text')]//text()
will get you the content of the Tweet.
The full working example:
from lxml import html
import requests
page = requests.get('https://twitter.com/UniteAlbertans/status/899468829151043584')
tree = html.fromstring(page.content)
tree.xpath('//div[contains(#class, "permalink-tweet-container")]//p[contains(#class, "tweet-text")]//text()')
results in:
['Breaking:\n10 sailors missing, 5 injured after USS John S. McCain collides with merchant vessel near Singapore...\n\n', 'https://www.', 'washingtonpost.com/world/another-', 'us-navy-destroyer-collides-with-a-merchant-ship-rescue-efforts-underway/2017/08/20/c42f15b2-8602-11e7-9ce7-9e175d8953fa_story.html?utm_term=.e3e91fff99ba&wpisrc=al_alert-COMBO-world%252Bnation&wpmk=1', u'\xa0', u'\u2026', 'pic.twitter.com/UiGEZq7Eq6']

Photos uploaded to page as user are invisible to others

I have successfully uploaded photos to a Facebook Page that I am not the administrator of using the iOS FacebookSDK. However those photos are invisible to everyone except the uploader.
The page has the "Everyone can post to Page's timeline" and "Everyone can add photos and videos to Page's timeline" settings on.
I am using the following code, where self.photo is a UIImage:
FBRequest *request = [FBRequest requestForUploadPhoto:self.photo];
request.graphPath = #"<pageid>/photos";
request.session = [FBSession activeSession];
FBRequestConnection *conn = [FBRequestConnection new];
[conn addRequest:request completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { ... }];
[conn start];
The upload / post is successful. If you view the page in question, as the user who uploaded the photo, you can see the photo on the page in the "Recent Posts by Others" box.
However, if you view that page as another user - no activity appears on the page and the "Recent Posts by Others" box is empty.
If that other user then uses the app to upload a photo in the same way, the same thing happens to them: they can see the photo they've uploaded but the first user cannot.
All photos uploaded by either user show to that user as "Shared with: Public" and "via" the application used. So it doesn't appear that they are hidden because of privacy or something like that.
I have seen many others post that they have been unable to upload photos to a page as a user (not the administrator of the page), e.g.:
Posting Photo to facebook fan page via iOS app by regular non-admin users
http://facebook.stackoverflow.com/questions/10795769/upload-photo-to-fanpage-from-application-user
http://facebook.stackoverflow.com/questions/7140097/facebook-create-app-for-page-to-upload-photos-to-pages-photo-album
http://facebook.stackoverflow.com/questions/12897746/user-image-upload-to-page-gallery
I have been able to upload the photo, but it only shows to the uploader! Is this some functionality that has changed? Am I running into a bug? It's very strange, I would love it if someone could shed some light!
Unfortunately it appears that while the Facebook API allows you to get further, it does still not work to upload photos to the timeline of a page.
This bug appears to be related and has been open for a while:
https://developers.facebook.com/bugs/246002638848837/
Success! It works, I have posted as a user to a Facebook page.
Where self.photo is an NSData:
NSDictionary *parameters = #{#"test.jpg": self.photo, #"message": self.message};
FBRequest *request = [FBRequest requestWithGraphPath:#"<pageid>/photos" parameters:parameters HTTPMethod:#"POST"];
Then the rest as per my question above.

Facebook: Change the description/title that appears in a facebook post when I post a URL

I am using a PHP script to post a URL to a fan page that I am an admin of, but the contents of the post always appear as defined by page's <title> tag/<meta type="description"> tag.
Can't the contents of facebook post be changed by using facebook's open graph description(og:description)/title(og:title) tags in the page being posted?
The title can be changed using og:title as long as the page has less than 50 likes (otherwise it is locked in by Facebook). The og:description can be changed at any time.
See: https://developers.facebook.com/docs/opengraph/

posting page title on the facebook when user clicks on like button in asp.net

I have a like button on my website, whenever I click on the like button, the information is posted on my facebook wall with proper url, but the issue is there is no proper page title, and image on the facebook wall, I want to customize this information. I mean I want to post the page title, coz my page title changes for every article, and also I want to post the image of the article on the facebook...
How can I post the customize information on the facebook on like button click.
You will need to include some open graph tags on your site in order to customize the title.
You would do this with
<meta property="og:title" content="My Title"/>
https://developers.facebook.com/docs/opengraph/
Make sure to include all the required tags (title, url, site_name, type, image) and to include the namespaces:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="https://www.facebook.com/2008/fbml">
Hope this helps.