facebook publish_action not supported? - php

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.

Related

Hide URL in final tweet and leave only the card

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.

Specify caption when posting Custom Story via Facebook Graph API

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".

Why is Facebook api Privacy parameters- custom - allow ignoring friend id's?

I am unable to allow specific user id's to see my uploaded photo via the privacy parameters. This is my code:
$privacy = array(
'value' => 'CUSTOM',
'allow' => '619211114855652',
);
$photo = (new FacebookRequest(
$session,
'PHOTO',
'/me/photos',
array (
'source' => new CURLFile ($location.$name),
'message' => ($caption),
'privacy' => json_encode ($privacy)
)
))->execute()->getGraphObject()->asArray();
The friend id is retrieved using the get /me/friend request but this is being ignored as when I run this, it sets to "only me" as my privacy setting. Having googled this, I found out that if CUSTOM and allow is not specified, it will by default set it to "only me" who can see the post. When I replace the id with "ALL_FRIENDS" it works. I really do not understand why it isn't working, I assume facebook is ignoring the id but I can't think why. Has anyone managed to set their privacy to specific users?
Also note, this does not override my max privacy settings of the app, as my max setting is set to "friends". And I am just trying to limit the friends who can see the post.
I've tested your code with a new application and I've found that it's the initial privacy setting you sent when adding the application causes this behaviour.
Go to Settings > Apps > Your App and change the "Visibility of App" setting to Friends or Public.
Then re-test your code and you'll see that it does indeed work work with a valid friend ID.
It was a bug. I reported it and now it works :)

Using graph API and creating a link on the event page

I must be missing something really obvious.
I have created successfully an Event with the graph API
I now want to put a link on the event page
When i use the code below, it creates a message but not a link. So please someone what am i missing. I do get a linkid back as well as you can see the message on the page.
So this is the pretty simple code.
$fb = new Facebook(array(
'appId' => FB_APP_ID,
'secret' => FB_APP_SECRET,
'cookie' => true,
'fileUpload' => true
));
$fb->setAccessToken($_SESSION[ $eid.'_FB_USER_ACCESSCODE' ]);
$data = array( 'access_token' => $_SESSION[ $eid.'_FB_USER_ACCESSCODE' ],
'link' => 'http://www.thedomain.com',
'message' => "To purchase your tickets"
);
$result = $fb->api($newFBEventId."/feed","post",$data);
Thanks
This is a Bug and its reported and marked as confidential
With the below text and its also contain security hole
bug report link
Below is my bug report text.
Other details on this report are shown to Facebook employees only
I recently attempted to post on an event's wall using the Graph API, but only the message is posted; Everything else is not showing. e.g.
Link
Picture
etc
There is one more big thing that the post doesn't show; That this post is post "via a Facebook app"
Note: posting on a page or user wall worked and also normal messages posted on an event 's wall.
The most important thing is when the post is shown on the event's wall "it does not show that its posted by a Facebook Application".
This is very dangerous; For example I can make an application and post nonsense on a user's event wall. People will think that this is posted by the user.
Thanks

Managing Facebook Pages using PHP

I'm looking to integrate my current website more deeply with Facebook using a Fan Page (notice: I did noticed the Open Graph protocol that Facebook support but i'm looking to create a website-wide fan page).
I know that you can create and manage Fan Pages using Facebook, but I'm looking for a way to do that using a PHP script - for example, post to the Fan Page wall, create events using the Fan Page and ideally - create secondary Fan Pages on the fly.
After looking around in Facebook's developer section I didn't find a method to do those tasks from outside using the Facebook API.
So my question is: how would you accomplish that?
Thanks!
Publishing posts to your Page, and creating Events, are both relatively trivial tasks. You can use the Graph API to do that.
Check out the area about Publishing specifically. It gives you the general overview of how publishing works, and this can be applied all over the Graph.
Also, the documentation about the Events portion of the Graph API has an example cURL post for how to create a new event via the Graph API.
Posting anything to your Facebook page is going to require you have the manage_pages extended permission, and it's probably a good idea to get the offline_access permission also.
An example of both posting to your Page wall and creating an event (in php) would look a lot like this:
<?php
require 'facebook.php';
$fb = new Facebook(array(
'appId' => FB_APP_ID,
'secret' => FB_APP_SECRET,
'cookie' => true
));
$your_page_id = '123123123';
//get the access token to post to your page via the graph api
$accounts = $fb->api("/me/accounts");
foreach ($accounts['data'] as $account)
{
if ($account['id'] == $your_page_id)
{
//found the access token, now we can break out of the loop
$page_access_token = $account['access_token'];
break;
}
}
try
{
//publish a story to the page's wall (as the page)
$post_id = $fb->api("/{$your_page_id}/feed", "POST", array(
'message' => "Hello to all my fans, I love you!"
'access_token' => $page_access_token;
));
echo "Post published. ID: {$post_id}<br>";
//create a new event.
$event_id = $fb->api("/{$your_page_id}/events", "POST", array(
"name" => "My Totally Awesome Event, You Better Show UP!",
"start_time" => time(), //it starts now...duh!
"location" => "Anywhere, USA"
));
echo echo "Event created. ID: {$event_id}<br>";
}
catch (Exception $e)
{
var_dump($e);
}
As for creating Pages on the fly, the only way you can do that is by using the Open Graph Protocol. The only restriction here is that pages have to have unique URLS. So you can assign each of your Open Graph objects a unique ID, and give them a URL like http://www.mysite.com/pages?id=123456. This will let you output the Open Graph tags required to generate the page on FB. You can then use the Graph API to get the ID of the Open Graph object after someone likes it like so: http://graph.facebook.com/?ids=http://www.mysite.com/pages?id=123456.
You can publish to these Open Graph objects the same exact way you'd publish to a standard Facebook Page.
Hope that helps!

Categories