When posting a custom story via the Graph API, is it possible to specify/change the caption of the attachment when I post the story to the user's account, i.e. on the fly?
Right now it defaults to the name of the app posting the action ("Action Center - Scale Review" in the screenshot).
I see in the docs for stories that I can specify up to 4 captions via the UI. But it's not clear to me when these take affect; for example, in the screenshot, I have 4 captions specified for that story - but none are showing. Plus, that's not on the fly/dynamic which is what I'm looking for.
It doesn't look like passing "caption" as an option when posting the action has any effect, nor does a "og:caption" param on the custom object.
I can specify the caption when posting a link via other methods - for example, when publishing a post on a users wall, I can specify the caption for the link.
I am not sure whether those “caption” fields are shown any more for simple objects (the docs might be outdated on this). Even if they are, you can not populate them dynamically, apart from using object property placeholders.
I think you best bet is to use the description (the “Heres a A Demo […]” line in your screenshot) to place the information you want to publish. You can create objects “on the fly” using the Object API. If you want individual objects on a “per user” basis, then this would be the way to go.
To make the captions dynamic you have to add curly braces : example :
by {}
When typed "{" it will show a drop down with your custom objects and you can use your objects to make captions dynamic.
However there is a huge limitation of bringing these captions into new lines.
It's clearly stated in the documentation link you provided.
Here's the code:
$request = new FacebookRequest(
$session,
'POST',
'/me/feed',
array (
'message' => 'This is a test message',
'link' => '',
'picture' => '',
'name' => '',
'caption' => '',
'description' => '',
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
When you click on the arrow next to "link" in the Facebook Docs page, you'll see the other options related to the "link".
Related
I've developed an app in Laravel, using codebird-php, that's able to post tweets with images, videos and links. The code works as it's intended but I was told by my boss to hide the url in the final tweet and leave only the card, this for aesthetic purposes.
You can see what I'd like to do in the next pictures.
On top you can see a tweet from TechCrunch with a card but no url in body, this is wat I want to achieve.
However, I've also noted that there are tweets with cards and a visible url in the body. TechCrunch also as an example.
I've read into Twitter's API thinking the url might be an additional parameter as Facebook does, but I found nothing. I've also thought that it might be Twitter's site hiding the urls in web as in Twitter for Mac I can see the url.
I really don't know, I've been looking for a couple of days now and don't know what or how to do it. Does anyone know how to achieve that? Or am I right thinking that it's Twitter hiding the url in web?
Thank you all for your time.
EDIT:
Here's my code.
$sm = SocialScheduling::find($id);
$sm->update([
'persona_id' => $request->get('persona_id'),
'social_auth_id' => $request->get('social_auth_id'),
'social_scheduling_category_id' => $request->get('social_scheduling_category_id'),
'message' => $request->get('message'),
'post_link' => $request->get('post_link'),
'post_to_feed' => $request->get('ptf'),
'social_networks' => json_encode($request->get('social_networks')),
'facebook_pages' => json_encode($request->get('facebook_pages')),
'programmable_type' => $request->get('programmable_type'),
'programmable_id' => $request->get('programmable_id'),
'client_id' => $request->get('client_id'),
'image_url' => $request->get('image_url'),
'publish_time' => $request->get('publish_time')
]);
$sm->save();
$sm->load('persona','client','category','programmable','social_auth');
$persona = SocialAuth::find($sm->social_auth_id);
Codebird::setConsumerKey( Config::get('services.twitter.client_id'),
Config::get('services.twitter.client_secret'));
$tw = Codebird::getInstance();
$tw->setToken($persona->twitter_token,$persona->twitter_token_secret);
$data = [
'status' => $sm->message
];
$reply = $tw->statuses_update($data);
What my code does is it updates the SocialScheduling model, then it uses social_auth_id to find the model with the credentials and assigns it to $persona, afterwards I build the tweet adding the url to the tweet message, but I'd like to know if there's an additional parameter, like Facebook does, where I can send the url. I didn't see anything in Twitter's docs.
I'm a bit confused. I've read the docs and tutorials on the web for getting permission for "publish_action" so that the user can choose the option to automatically post a link on their FB feed when they create a new post on my site (instead of having to do it manually every time).
I set up the page to obtain the user permission for "publish_action" and created the parameters (as shown below). THis works great when I do it, but I am using my developer account. On the facebook developer group I was informed that we are not able to write the message, caption, or link description for the user.
Is this really the case? If so, how is that different than the share dialogue? What's the point in the publish_action permission? Is the publish_action deprecated?
$params = array(
"message" => "I just added a new post.",
"link" => $post_link,
"picture" => "http://example.com/fbpreview2.jpg",
"name" => "Name of website",
"caption" => "www.example.com"
, "description" => "This is a website"
);
$request = ( new FacebookRequest( $session, 'POST', '/me/feed', $params ) )->execute()
The Facebook Platform Policy's documentation on prefilling requires that the user have typed everything in the message parameter.
If you post only the contents of the user-generated post, you should be compliant with the rules. Adding anything to it that the user didn't explicitly type - additional copy, links, hashtags, etc. - is forbidden.
As an example, if I posted a blog post to a blogging system, you could provide a "post this to Facebook too" checkbox/button. Posting the blog entry's exact user-typed text would be OK, but posting a message like "I just blogged on example.com/post.html" would be forbidden.
/me/feed doesn't accept caption or description parameters, so it won't matter if you pre-fill them - they don't do anything.
I have a running workflow which I would like to post fields to via an API call (see below):
$ret = invokeFlowgear(
"https://domain.flowgear.io/salesbooks",
"username",
"password",
30,
array(
'name' => 'Introduction to Data integration with Flowgear',
'isbn' => 'X-XXX-XXXX',
'qis' => 0,
'price' => 250.99,
'author_id' => 3
)
);
Eventually this call should result into the workflow inserting the data onto the table and returning a success message.
What do I need to have this achieved with a workflow via an API?
You need to accept the raw HTTP POST body into the Workflow. To do that, set an appropriate URL ("/salesbooks/") in the workflow detail pane and set the method to POST.
Then drop in a Variable Bar and add the special property FgRequestBody. Optionally also add FgRequestContentType so you can inspect the content type of the message being received.
Create an HTTP POST to that Workflow and you can see what's coming through to the FgRequestBody property (it will show in the Start entry in the activity logs).
If you need to convert between JSON and XML, using JSON Convert.
Using the Yammer REST API I can include Open Graph (og) elements that will cause a graphic block to appear at the bottom of my generated post in Yammer:
$data = array(
'title' => $title,
'body' => $body,
'group_id' => $yammer_group_id,
'og_url' => $url_for_this_item,
'og_title' => $title,
'og_site_name' => 'Title of Our Site'
);
$json = json_encode($data);
$result = post_yammer($yammer_token, 'messages.json', $json);
When the graphic block is hovered over in Yammer, a strip of links appears at the bottom, one of which is "Share".
Is there any way to disable this functionality per-post (or overall for that matter) in Yammer - either the "Share" link specifically or the whole strip of links? My client has certain posts they'd like to make but discourage sharing.
I am guessing the answer is "no" - it's a pretty specific request and unlikely to be a common one - but figure someone might have an insight.
It's not possible to disable the links including Share from appearing in the Yammer user interface.
I haven't find anything related. Might be i would have searched wrongly.
I want to tag friends in video.
How do i do that using graph api in facebook?
It is possible to tag friends in a video, but it's just not in the documentation. I've searched quite some time myself to no avail, but then tried a couple of things and got it working.
The two permissions you need are publish_actions and user_videos.
It works quite similar to tagging photos, which is done with the /{photo_id}/tags endpoint. Although the video equivalent /{video_id}/tags is nowhere to be found in the documenation, it apparently does exist.
With photos you can supply the parameter tags as an array. Video tagging only supports one tag at a time with the tag_uid parameter. So if you want to tag multiple people, you'll have to do multiple posts.
This is the final working solution with the PHP SDK:
$facebook = new Facebook(array('[YOUR_APP_ID]', '[YOUR_APP_SECRET]'));
$response = $facebook->api('/me/videos', 'POST', array(
'access_token' => $facebook->getAccessToken(),
'title' => '[YOUR_TITLE]',
'description' => '[YOUR_DESCRIPTION]',
'source' => '#' . realpath('[PATH_TO_YOUR_VIDEO')
));
$facebook->api('/' . $response['id'] . '/tags', 'POST', array(
'access_token' => $facebook->getAccessToken(),
'tag_uid' => '[FRIENDS_FACEBOOK_ID]'
));
Read this
https://developers.facebook.com/docs/reference/api/post/
The post supports adding message tags.
Under the message_tags column
object containing fields whose names are the indexes to where objects are mentioned in the message field; each field in turn is an array containing an object with id, name, offset, and length fields, where length is the length, within the message field, of the object mentioned