Publish embed video in Facebook Wall - facebook

I'm trying to publish a video using the PHP SDK. Use the method 'feed' and and then I show the code you i'm using. I using a flv video.
$response = $this->facebook->api('/me/feed/', 'POST', array(
'message' => 'My custom message',
'name' => 'Whatever name',
'description' => 'Whatever description',
'link' => 'http://localhost/my_proyect/',
'picture' => 'http://localhost/my_proyect/my_image.png',
'source' => 'http://localhost/my_proyect/videos/my_video.flv',
'actions' => array(
array(
'name' => 'Some Actions',
'link' => 'http://localhost/my_proyect/'
)
),
'caption' => 'Cool Video'
));
echo json_encode($response);
In my HTML i put the FB meta tags.
<!-- FB Meta Tags -->
<meta property="fb:app_id" content="xxxxxxxxxxxxx" />
<meta property="og:url" content="http://localhost/my_proyect/" />
<meta property="og:video" content="http://localhost/my_proyect/videos/my_video.flv" />
<meta property="og:video:height" content="640" />
<meta property="og:video:width" content="385" />
<meta property="og:video:type" content="application/x-shockwave-flash" />
<!-- FB Meta Tags END -->
When I see the response. Return a array with the ID of post.
When I see the user's wall, just see the post with the text but not the embedded video or image.
What is it I'm doing wrong in my code? Do I need to pass a player or the player that plays my video is by default? Or do not work because I'm on my localhost?
Thanks in advance.

Related

PHP - Get Meta Information by EmbedURL

How I will get meta information specified by EmbedURL? I have tried get_meta_tags('raw_html'). But it returns nothing.
MY HTML:
<!--Video 1-->
<div class="embed-responsive-item" itemprop="video" itemscope="" itemtype="http://schema.org/VideoObject">
<video class="embed-responsive-item" controls="" loop="">
<source src="INTERNAL_VIDEO_URL">
</video>
<meta itemprop="name" content="">
<meta itemprop="duration" content="">
<meta itemprop="thumbnailUrl" content="THUMBNAIL_URL">
<meta itemprop="embedURL" content="INTERNAL_VIDEO_URL">
<meta itemprop="uploadDate" content="2021-03-27T04:10:1600Z">
</div>
<!--Video 2-->
<div class="embed-responsive embed-responsive-16by9" onclick="loadYoutubeVideoThroughYTApi(this)" data-src-id="player-1" data-yut-var="YOUTUBE_VIDEO_ID">
<meta itemprop="description" content="META_DESCRIPTION_2">
<meta itemprop="duration" content="PT1M13S">
<meta itemprop="name" content="META_TITLE_2">
<meta itemprop="thumbnailUrl" content="https://i.ytimg.com/vi/YOUTUBE_VIDEO_ID/maxresdefault.jpg">
<meta itemprop="embedURL" content="https://www.youtube.com/embed/YOUTUBE_VIDEO_ID">
<meta itemprop="uploadDate" content="2019-02-04T11:00:43.000Z">
</div>
<!--Video 3-->
<div class="embed-responsive-item" itemprop="video" itemscope="" itemtype="http://schema.org/VideoObject">
<video class="embed-responsive-item" controls="" loop="">
<source src="INTERNAL_VIDEO_URL_2">
</video>
<meta itemprop="name" content="">
<meta itemprop="duration" content="">
<meta itemprop="thumbnailUrl" content="THUMBNAIL_URL_2">
<meta itemprop="embedURL" content="INTERNAL_VIDEO_URL_2">
<meta itemprop="uploadDate" content="2021-03-27T04:10:1600Z">
</div>
As you can see the html contains three different videos with three different meta properties. So the result array should be look like this
Desired Output:
Array
(
[0] => Array
(
[url] => INTERNAL_VIDEO_URL
[meta_name] => NULL
[meta_description] => NULL // as you can see no meta tags for description
[meta_duration] => NULL
[meta_thumbnail] => THUMBNAIL_IMAGE_URL
[upload_date] => 2021-03-27T04:10:1600Z
)
[1] => Array
(
[url] => https://www.youtube.com/embed/YOUTUBE_VIDEO_ID
[meta_name] => META_TITLE_2
[meta_description] => META_DESCRIPTION_2
[meta_duration] => PT1M13S
[meta_thumbnail] => https://i.ytimg.com/vi/YOUTUBE_VIDEO_ID/maxresdefault.jpg
[upload_date] => 2021-03-27T04:10:1600Z
)
[2] => Array
(
[url] => INTERNAL_VIDEO_URL_2
[meta_name] => NULL
[meta_description] => NULL // as you can see no meta tags for description
[meta_duration] => NULL
[meta_thumbnail] => THUMBNAIL_IMAGE_URL_2
[upload_date] => 2021-03-27T04:10:1600Z
)
)
How will I get the set of array like this?

facebook share specific dynamic content according to page

I have a websites displaying cars. if user clicks on each car, it will direct to each car info page. I want to share each car content(image,title,description,url).
For ex.if user clicks on car with id 1,share dialog will display content for that car id 1, and if user clicks on car with id 2,share will display content for car id 2. I have googled for solution but have not found it. Below is my code.
<head>
<meta property="og:url" content="<?php echo 'http://motorcarmyanmar.com';?>" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Buy,Sell,Rent,Or Lease Cars Or Car Accessories In Myanmar" />
<meta property="og:description" content="Car Sales,Car Rentals,Car Accessories Sales" />
<meta property="og:image" content="http://motorcarmyanmar.com/pictures/car1.png" />
<meta property="og:image:alt" content="car picture"/>
<meta property="og:image:width" content="500" />
<meta property="og:image:height" content="400" />
<meta property="fb:app_id" content="1538657022815637" />
</head>
In the beginning of body.
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '1538657022815637',
autoLogAppEvents : true,
xfbml : true,
version : 'v2.8'
});
FB.AppEvents.logPageView();
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8&appId=1538657022815637";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
In the car info page.
<script>
document.getElementById('shareBtn').onclick = function() {
var title,description,image;
title=$('#title_fb').val();
description=$('#description_fb').val();
image=$('#image_fb').val();
FB.ui({
method: 'share_open_graph',
action_type: 'og.shares',
action_properties: JSON.stringify({
object: {
'og:url': window.location.href,
'og:title': title,
'og:description': description + ' Lakhs',
'og:image': image,
'og:image:width':'500',
'og:image:height':'400'
}
})
},
function (response) {
// Action after response
});
}
</script>
With the codes i have given, the dynamic share works. But i want the share image to be bigger not a thumbnail. I read that if share reaches 50 counts,og tags can not be edited. So is there another way to share or is this way right. I saw other website pages sharing dynamic content without creating objects.
Follow Facebookes best practices about pictures sizes: https://developers.facebook.com/docs/sharing/best-practices/#images
Also, you should use a separate URL with a separate og:url tag for each share and just method: 'share' without other parameters. That share_open_graph method is just a workaround.
For example:
<meta property="og:url" content="<?php echo 'http://motorcarmyanmar.com/?id=' . $_GET['id'];?>" />
Of course you need to check if the parameter even exists, but it´s just an example.
The url is
http://www.motorcarmyanmar.com/pages/car_details/ca36?ca36=Details&Details=ca36
<head>
<?php
$title_header="";
$description_header="";
$features_header="";
$image_header="";
if(isset($_GET['Details']))
{
$car_id=$_GET['Details'];
$car_details= //get from database width $car_id;
$title_header=$car_details['header'];
$description_header=$car_details['description'];
$image_header=$car_details['image'];
}
?>
<!-- You can use Open Graph tags to customize link previews.
Learn more: https://developers.facebook.com/docs/sharing/webmasters -->
<meta property="og:url" content="<?php echo 'http://motorcarmyanmar.com' . $_SERVER['REQUEST_URI'];?>" />
<meta property="og:type" content="website" />
<meta property="og:title" content="<?php echo (!empty($title_header)?$title_header:'Some Buy,Sell,Rent');?>" />
<meta property="og:description" content="<?php echo (!empty($description_header)?$description_header:'Car Sales,Car Rentals,Car Accessories Sales');?>" />
<meta property="og:image" content="<?php echo (!empty($image_header)?$image_header:'http://motorcarmyanmar.com/images/icons/car1.jpg');?>" />
<meta property="og:image:alt" content="car picture"/>
<meta property="og:image:width" content="500" />
<meta property="og:image:height" content="400" />
<meta property="fb:app_id" content="1538657022815637" />
</head>
this is what i did. With this code, some pages show right share content(title,description,image),some pages show default homepage share content. But only url is right for each page. Is the code in right direction?

facebook unity sdk /user/feed embed youtube with link

I am using Facebook unity sdk 7.0.2
I am trying to share a link to my canvas game with a mediasource to my youtube video channel.
When I set mediaSource to http://www.youtube.com/e/xxxxxxx&autoplay=1 the link gets shared, and the picture appears, but there is no play button and no video, so when I click the link I am forwarded to my canvas.
var publishData =
new Dictionary<string, string>() { { "link", link },
{ "picture", pictureLink },
{ "name", linkName },
{ "caption", linkCaption },
{ "description", linkDescription },
{ "source", mediaSource },
{ "ref", feedref },
};
FB.API("/me/feed", HttpMethod.POST, FacebookFeedLog, publishData);
I tried to create an html with og:type set to video and upload it to my server, then set the mediasource to the new html file, in that case I just get a blank picture and a link to my canvas.
<meta property="fb:app_id" content="xxxxx" />
<meta property="og:type" content="video" />
<meta property="og:url" content="xxxx" />
<meta property="og:title" content="Watch video" />
<meta property="og:description" content="I am playing games, why not try it." />
<meta property="og:image" content="http://i2.ytimg.com/vi/xxxx/hqdefault.jpg" />
<meta property="og:video" content="http://www.youtube.com/e/xxxxautoplay=1" />
<meta property="og:video:width" content="398" />
<meta property="og:video:height" content="224" />
<meta property="og:video:type" content="application/x-shockwave-flash" />
Is there a way to share a link to canvas application with an embedded youtube video?
Thanks for advance.
Almost there, try removing media source, and setting the link parameter to your OG object you hosted on your server.

How to add the author name when sharing on Facebook

I'm just trying to add the name of the author in the share box dialog in FB
I've added the following meta and og property:
<meta name="author" content="foutight.com">
<meta property="og:type" content="article"/>
<meta property="og:article:author" content="foutight.com"/>
But no success. Any suggestions. Thanks.
That comes from the <meta name='author' content='...'/> section. It looks like it's appearing on http://foutight.com/posts/photo/242 - maybe you've just got a cached page?
Run it through oglint.com, and try and re-scrape it.
Try the author whitout the "og".
<meta property="og:type" content="article"/>
<meta property="article:author" content="foutight.com"/>
<meta name="author" content="foutight.com">
<meta property="article:author" content="https://www.facebook.com/author_profile" />
article:author may contain an array of Facebook profile URLs or IDs of the authors for this article.
https://developers.facebook.com/docs/reference/opengraph/object-type/article/
Open function.php and add code :
function author_chauit() {
if ( is_singular('post') ) {
echo '<meta name="author" content="'.get_the_author().'">';
} else {
echo '<meta name="author" content="'.get_bloginfo( 'name' ).'">';
}
}
add_action( 'wp_head', 'author_chauit' );
notes : add in end functioncode

Post swf with parameters to facebook via application

I have a facebook application where the user choose 4 of his friends and then it creates a video (swf) with the pictures of your friends in it (loaded via xml). So I need to share this video on the user timeline. Everything works fine but the video is not embedded in the post on his timeline, there is only a post with the link to the page in it.
The weird thing is, if I post the url directly on my timeline, the video is embedded, but not if the same link is posted via the application.
here is my code called by the share button in js :
function postToFeed() {
var obj = {
method: 'feed',
link: 'https://mysite.com/flash/share-page.php?id=22',
picture: 'https://mysite.com/images/video-preview.jpg',
name: 'Name',
caption: 'Caption',
description: 'Description'
};
function callback(response) {
//some code here
}
FB.ui(obj, callback);
}
and the code in my share-page.php
<?php
$id_inscription = $_GET['id'];
$video_url = 'https://mysite.com/flash/share-page.php?id=22';
$video_preview_image = 'https://mysite.com/images/video-preview.jpg';
?>
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="content-language" content="en">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta property="og:video" content="<?php echo $video_url; ?>"/>
<!-- Open grah tags for Facebook -->
<meta property="og:title" content="Test video player" />
<meta property="og:description" content="A video player interface experiment." />
<meta property="og:type" content="video" />
<meta property="og:url" content="<?php echo $video_url; ?>"/>
<meta property="og:image" content="<?php echo $video_preview_image; ?>"/>
<meta property="og:site_name" content="Site name"/>
<!-- Video specific open graph tags -->
<meta property="og:video" content="<?php echo $video_url; ?>" />
<meta property="og:video:secure_url" content="<?php echo $video_url; ?>" /> <!-- Required for people on Facebook who have secure browsing enabled! -->
<meta property="og:video:width" content="325" />
<meta property="og:video:height" content="180" />
<meta property="og:video:type" content="application/x-shockwave-flash" />
<script src="js/swfobject.js"></script>
<script>
var flashvars = {
xmlUrl:"xml/data-<?php echo $id_inscription; ?>.xml",
policyFileUrl:"http://profile.ak.fbcdn.net/crossdomain.xml"
};
var params = {
menu: "false",
scale: "noScale",
allowFullscreen: "true",
allowScriptAccess: "always",
bgcolor: "",
wmode: "opaque"
//wmode: "direct" // can cause issues with FP settings & webcam
};
var attributes = {
id:"content"
};
swfobject.embedSWF(
"app.swf",
"altContent", "480", "270", "10.0.0",
"expressInstall.swf",
flashvars, params, attributes);
</script>
</head>
<body>
<div id="altContent">
<p>Get Adobe Flash player</p>
</div>
</body>
</html>
Found it, in the javascript you have to add
source: 'https://mysite.com/flash/app.swf'
DOesnt work for me .
Also facebook says ,It is NOT supposed to work By Design .
https://developers.facebook.com/bugs/589975484398226?browse=external_tasks_search_results_526fc388b99e18881434478
Please share here your code snippet if you could make it work . I have the meta tags taking care for the secure video Url as well .