Facebook publish to stream and attach link - facebook

I'm currently using the Facebook Developer Toolkit to publish to my organization's Facebook page. I'd like to be able to attach a link, but can't quite seem to figure out the syntax. Here's what I'm trying.
ConnectSession fbSession = new ConnectSession(API_KEY, API_SECRET);
Api fbApi = new Api(fbSession);
attachment attach = new attachment();
attach.href = "http://www.google.com";
attach.caption = "Google";
attach.name = "Google";
String post = "Here's a cool new search engine I found!";
fbApi.Stream.Publish(post, attach, null, null, Convert.ToInt64(fanPageId));
Here's what I'm going for:

Don't use that the Facebook Developer Toolkit because it's not being properly supported (personal opinion :P) use the FacebookC#SDK
What you want to post are referred to as 'action_links' and can only be posted using the OLD REST API, not the new graph api (https://api.facebook.com/method/stream.publish)
In order to post it you need to encode the JSON in the form:
action_links: [
{ text: "TITLE", href: "LINK"}
]

Related

How can we dynamically populate quick replies of facebook messenger from a JSON object?

I really liked the Facebook quick replies feature which helps us guide the conversation with the user.
My context is I am building a form fill bot. There are a few questions a user is asked before he is redirected to the appropriate page. The questions and their options come as a JSON object.
I would like to make the question as a text message and the options as quick replies. This would greatly help the user quickly answer the few questions and get the form filled.
I am stuck at the point where I need to populate the quick replies options with the questions' options.
I am using Microsoft Bot builder framework to build the bot
Channel's specific features (such as the Quick Replies from Facebook) are supported through the ChannelData (C#) / sourceEvent (Node) fields. So you need to send the specific info through it so Facebook can understand it and react accordingly.
Here is a quick example showing how to send Facebook's Quick Replies.
var channelData = JObject.FromObject(new
{
quick_replies = new dynamic[]
{
new
{
content_type = "text",
title = "Blue",
payload = "DEFINED_PAYLOAD_FOR_PICKING_BLUE",
image_url = "https://cdn3.iconfinder.com/data/icons/developperss/PNG/Blue%20Ball.png"
},
new
{
content_type = "text",
title = "Green",
payload = "DEFINED_PAYLOAD_FOR_PICKING_GREEN",
image_url = "https://cdn3.iconfinder.com/data/icons/developperss/PNG/Green%20Ball.png"
},
new
{
content_type = "text",
title = "Red",
payload = "DEFINED_PAYLOAD_FOR_PICKING_RED",
}
}
});
reply.ChannelData = channelData;
You can also find more details about how to use new Facebook's features with BotFramework in this blog post.
Please note that in the particular case of Quick Replies, the BotFramework team is adding support to them in the library. The commit is still in the develop branch; so it's not yet public (you can still build the library and reference to that instead of the public NuGet)

Auto create google groups from sheets

Searched the net, youtube, and google forums/documentation but can't seem to find this one even if it is possible.
I'm using a google form as a starting point for a workflow that then gets turned into a google group. Is there any scripts that can auto create a google group from the google forms output in sheets once form is submitted?
Thanks in advance.
I haven't tested this yet, so just give it a try. This is what I've found. Directory API let's you create a group by making a POST URI request:
https://www.googleapis.com/admin/directory/v1/groups
with request body:
{
"email": "sales_group#example.com",
"name": "Sales Group",
"description": "This is the Sales group."
}
Since you are using Google Forms, the option would be to use AppScript to perform the XHR request.
Try to make use of Class UrlFetchApp in Appscript.
var options =
{
"method" : "post",
"payload" : payload
};
UrlFetchApp.fetch("http://example.com/upload_form.cgi", options);

how to change sender name with facebook api

hi I use facebook application and I want send feed message to page wall
$accesstokens = 'blalbalba';
$post = array(
'access_token' => $accesstokens,
'message' => 'This message auto created - ' . date('d/m/Y H:i:s')
);
I try everythin from , to ,user
I try graph api explorer
when I try send message with token
facebook api add extra this code to message
"application": {
"name": "Application name",
"namespace": "application_namespace",
"id": "app id"
},
but I try send message normally from facebook and this code not in there
only adding this code try facebook api
and I see the application name on wall message "Share by Application"
How I change this ? I create page and when I try send message with facebook api and I sending message but I dont want see application name on my page wall
Like CBroe says in his comment, you are not allowed to auto-post any content, or use pre-filled comments/messages/captions. This is explained in Facebook's policy
There is also no way to remove app attribution data when creating content from an app. This is regardless of what SDK you are using. Even if you don't use an SDK, but only the Graph API, your content will contain app attribution data.

Facebook public posts I make using the Open Graph API are not seen by friends

I'm making a simple Facebook app that posts updates to the user's timeline using node.js and Facebook's Open Graph API. Even though I can see the posts I make using the OG API on my timeline (and it has the globe icon identifying that it's a public post, see pic below), none in my FB friend network can see it.
Here's a screenie of a public post I made via OG API showing up on my timeline, along with a post from a 3rd party app (Pool practice) for comparison:
Now here's the screenie of my friend's timeline showing only the Pool Practice post, the post from my app is nowhere to be seen...
I've checked the app settings and permissions as well as the OG API options, but haven't seen anything that points to how I can solve this problem. Here's the node.js code I'm using to post the updates:
// app permissions set to 'publish_actions' and 'publish_stream'
// I do the auth dance here to get the access_token and store it in session as fb_token
var request = require( 'superagent' ); // module from TJ Holowaychuk similar to "request"
request
.post( 'https://graph.facebook.com/me/feed?access_token=' + req.session.fb_token )
.send( { message: 'posting via node.js' } )
.set( 'Content-Type', 'application/x-www-form-urlencoded' )
.end( function( response ) {
log( response );
});
The code above works and the post shows up on my timeline, but no one else is able to see it.
Anyone know a way out of this?
you need to submit each action for Facebook validation before your friends can view it. Only users defined as developpers for the app are allowed to view those timeline messages.

Is there a way to insert an #mention into a Facebook status update posted with pyfacebook?

I have some code like the following in my application:
message = "Hi, #John Doe!"
postID = fb.stream.publish(
message = loader.render_to_string('wall_post.phtml', {'message':message}),
action_links = simplejson.dumps([{'text': "Check out blah", 'href': "http://blah.dev"}]),
target_id = 'nf'
)
Is there any way to represent a facebook #mention in the message string so that facebook converts it to a profile link for the mentioned user?
I've also been looking for an answer to this. The facebook website uses the format:
#[139730900025:PhotoGrabber] is awesome
to represent the links but I haven't been able to make that work. I re-posted a thread on the facebook forum under the "Stream" category since your post wasn't getting any attention:
http://forum.developers.facebook.com/viewtopic.php?id=47885
Mention it's partially available by open graph now. You can use only when posting an open graph ACTION
Check:
https://developers.facebook.com/docs/opengraph/mention_tagging/
It seems still impossible to use #mention tagging in classic feed posting via API
I'm pretty sure this is impossible at the moment. If it were posible by using the format that tam7t suggested it should work... Your best bet is asking them to add that to their api stream parser.
This is not possible at the moment, sorry.
AFAIK facebook's API does not allow this. The only approach that I know of at the moment would be to write a screen scraper to do these posts using the format described by tam7t's answer. If you use the mobile version of facebook's site (m.facebook.com) it makes it much easier.
NOTE: This might be a violation of Facebook's Application TOS.
Edit:
Here is some ruby code that will do the trick, using the Mechanize Gem
require 'mechanize'
agent = Mechanize.new
agent.user_agent_alias = 'Mac Safari'
page = agent.get('http://m.facebook.com')
form = page.forms.first
# enter credentials
form.pass = 'user password'
form.email = 'user#example.com'
page = agent.submit form
# go straight to page to post on
page = agent.get("http://m.facebook.com/wall.php?id=PAGE_ID_NUM")
form = page.forms.first
form.message = "#[139730900025:PhotoGrabber] is awesome"
page = agent.submit form
NOTE: Obviously (as tiagoboldt kindly pointed out) it would be wrong to store / utilise the credentials of other people in your application. This approach would only be appropriate for making posts from a facebook account that you controlled.
That said, back to the original question of putting an #mention in a wall post, I have noticed that whilst the post and #mention go up on the wall fine, this method does not propagate the post to the mentioned user/page's wall. Not sure if that is important to you.