Facebook - Post to multiple friends walls - facebook

I am using the Javascript SDK to post something onto a users friends wall:
var publish =
{
method: 'stream.publish',
message: 'Some kind of test',
uid: uid,
target_id: friendID,
attachment: {
name: 'Test',
caption: 'Facebook API Test',
description: ('Sure hope it worked!'),
href: 'http://www.test.com/',
media: [
{
type: 'image',
href: 'http://test.com/',
src: 'http://test.com/image.jpg'
}
]
},
action_links: [
{ text: 'Enigma Marketing', href: 'http://www.test.com/' }
],
user_prompt_message: 'Share your thoughts about test'
};
FB.ui(publish);
return false;
It is working ok, but I was wondering if there was a way I could post to MULTIPLE friends walls? I noticed that the pop shows a target friend in a list few, so it seems it may be possible to publish the post to more than one user. I can't find anything in the documentation, any help would be greatly appreciated.

No, you cannot post to multiple friends stream in one call.
The best way to do it is probably server side so that the user does not get multiple prompts. Notice this is usually discouraged though since it can be perceived as spam.
With your code, you can loop on just the send event part:
var publish =
{
method: 'stream.publish',
message: 'Some kind of test',
uid: uid,
attachment: {
name: 'Test',
caption: 'Facebook API Test',
description: ('Sure hope it worked!'),
href: 'http://www.test.com/',
media: [
{
type: 'image',
href: 'http://test.com/',
src: 'http://test.com/image.jpg'
}
]
},
action_links: [
{ text: 'Enigma Marketing', href: 'http://www.test.com/' }
],
user_prompt_message: 'Share your thoughts about test'
};
publish.target_id = friendID;
FB.ui(publish);
publish.target_id = friendID;
FB.ui(publish);
return false;

Related

Actions on google reservations for transaction API

We are building boot using action on builder SDK. In bot we have transaction related feature so we want to implement reservation feature to make appointment reservation. In our Bot we just need reservation. user can't cancel/delete reservation (As our member can contact the user for next 3 4 days, we are just asking user free time so we can contact user). (We did't have reservation feature yet but google team force us to do so). My Question is while implementing reservation we have https://developers.google.com/assistant/transactions/physical/dev-guide-physical-reservations#validate_transaction_requirements_optional this feature optional we are not implementing this, for second step we have to build Order like this https://developers.google.com/assistant/transactions/physical/dev-guide-physical-reservations#build_the_order
const order = {
createTime: '2019-09-24T18:00:00.877Z',
lastUpdateTime: '2019-09-24T18:00:00.877Z',
merchantOrderId: orderId, // A unique ID String for the order
userVisibleOrderId: orderId,
transactionMerchant: {
id: 'http://www.example.com',
name: 'Example Merchant',
},
contents: {
lineItems: [
{
id: 'LINE_ITEM_ID',
name: 'Dinner reservation',
description: 'A world of flavors all in one destination.',
reservation: {
status: 'PENDING',
userVisibleStatusLabel: 'Reservation is pending.',
type: 'RESTAURANT',
reservationTime: {
timeIso8601: '2020-01-16T01:30:15.01Z',
},
userAcceptableTimeRange: {
timeIso8601: '2020-01-15/2020-01-17',
},
partySize: 6,
staffFacilitators: [
{
name: 'John Smith',
},
],
location: {
zipCode: '94086',
city: 'Sunnyvale',
postalAddress: {
regionCode: 'US',
postalCode: '94086',
administrativeArea: 'CA',
locality: 'Sunnyvale',
addressLines: [
'222, Some other Street',
],
},
},
},
},
],
},
buyerInfo: {
email: 'janedoe#gmail.com',
firstName: 'Jane',
lastName: 'Doe',
displayName: 'Jane Doe',
},
followUpActions: [
{
type: 'VIEW_DETAILS',
title: 'View details',
openUrlAction: {
url: 'http://example.com',
},
},
{
type: 'CALL',
title: 'Call us',
openUrlAction: {
url: 'tel:+16501112222',
},
},
{
type: 'EMAIL',
title: 'Email us',
openUrlAction: {
url: 'mailto:person#example.com',
},
},
],
termsOfServiceUrl: 'http://www.example.com'
};
According to doc we have to create order object like above, but we are unable to find any doc what are optional filed in above object and what value to pass for reservationTime and userAcceptableTimeRange.
reservationTime: {
timeIso8601: '2020-01-16T01:30:15.01Z',
},
userAcceptableTimeRange: {
timeIso8601: '2020-01-15/2020-01-17',
}
Further more do we need to implement Set up asynchronous requests to the Orders API (https://developers.google.com/assistant/transactions/physical/dev-guide-physical-reservations#set_up_asynchronous_requests_to_the_orders_api) as we don't need to update user appoint time and user can't cancel appointment.
Is there any other way we can avoid reservation? please guide me, thanks in advance.

Wall Function not working in my app what's wrong?

This application seems to be working, every thing is fine but not for the wall and invite friends buttons. This is my app url: http://apps.facebook.com/mypersonnaldeathage
and the code of wall function:
FB.ui({
method: 'feed',
name: '<?= $appname;?>',
link: '<?= $canvasURL;?>',
picture: '<?php echo $callBackURL.$appimagename;?>',
caption: '<?=$wallpub;?>',
description: '<?= json_encode(strip_tags($line, ''));?>',
actions: [
{ name: '<?= $walllink;?>', link: '<?= $canvasURL;?>'}
],
message: ''
}
You issue lies in the action name not getting filled in
action links must have string 'href' and 'text' attributes
Your code you served to me
function publishToWall() {FB.ui({ method: 'feed', name: 'Your Personal Age Of Death', link: 'http://apps.facebook.com/persodeathage/', picture: 'http://www.septimageneracion.net/pdage/gravestone.jpg', caption: 'How and When Will You Die', description: '"You have 37 years to live...You will die from excitement when you get an email telling you that you won the Nigerian Lottery. \n"', actions: [ { name: '', link: 'http://apps.facebook.com/persodeathage/'} ], message: '' },function(response) { if (response && response.post_id) { //alert('Post was published.'); } else { //alert('Post was not published.'); } } );}
Notice the actions: [ { name: '', link: 'http://apps.facebook.com/persodeathage/'} ] part.

JS error posting to facebook wall

i am trying to post to my facebook wall. I have publish_stream rights. My code looks like:
//stream publish method
function streamPublish(name, description, hrefTitle, hrefLink, userPrompt){
FB.ui(
{
method: 'stream.publish',
message: '',
attachment: {
name: name,
caption: '',
description: (description),
href: hrefLink
},
action_links: [
{ text: hrefTitle, href: hrefLink }
],
user_prompt_message: userPrompt
},
function(response) {
});
}
function showStream(beschreibung,link){
//FB.api('/me', function(response) {
//console.log(response.id);
streamPublish(response.name,beschreibung, "orf.at",link, "Teile www.orf.at");
//});
}
and this is the error I got:
Fehler: uncaught exception: Error: http://static.ak.facebook.com wurde die Erlaubnis für das Lesen der Eigenschaft Proxy.InstallTrigger verweigert.
Did I miss anything?

Post image to user wall via FB Api

Hi i am trying to post image to friends wall from my FB app. I have this code, but dont know how to attach image to the post. It only posts text. Anybody has working example ? Or where i have error ? thanks.
FULL PATH TO IMAGE HERE - replaced with path to image
FULL PATH TO MY FB APP HERE - replace with path to fb app.
FB.ui(
{
target_id: '100000505490012',
method: 'stream.publish',
message: 'Just Testing!!!.',
attachment: {
name: 'test name',
caption: 'Caption here.',
description: (
'description here'
),
href: 'http://facebook.com/mysite'
},
media: {
type: 'image',
src: 'FULL PATH TO IMAGE HERE',
href:'FULL PATH TO MY FB APP HERE'
},
action_links: [
{ text: 'Code', href: 'FULL PATH TO MY FB APP HERE' }
],
user_prompt_message: 'Personal message here'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
The media attribute actually goes inside the attachment attribute.
FB.ui({
target_id: '100000505490012',
method: 'stream.publish',
message: 'Just Testing!!!.',
attachment: {
name: 'test name',
caption: 'Caption here.',
description: 'description here',
href: 'http://facebook.com/mysite',
media: [{ 'type': 'image', 'src': 'FULL PATH TO IMAGE HERE', 'href':'FULL PATH TO MY FB APP HERE'}]
},
action_links: [{ text: 'Code', href: 'FULL PATH TO MY FB APP HERE' }],
user_prompt_message: 'Personal message here'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);

Setting Facebook Publish Stream URLs

I am using facebook publishStream method in Facebook FBML Application, some other developer worked on it before me. I am using it some thing like this
Facebook.streamPublish('Publish Shirt Tale. <?php echo $canvasURL.'?req=tale-details&tale_id='.$tale_id?>', attachment);
But there is another url that is under the shared image, see below image for more info
So as in image there is encircle link, so that points towards some other page while I want it to the first page of app. It currently goes to a page some thing like this: http://apps.facebook.com/apps/application.php?id=xxxxxxxxxxxxx
so can any one tell that where can I specify that URL?
Thanks in advance
As per facebook is deprecating all FBML apps soon, I would advise you to look here, and try and create a dialog in this way. I can give you the script I'm currently using, where the link you circled directs to my app's home page. a note should be made- my app is an Iframe app.
<script type="text/javascript">
FB.ui(
{
method: 'stream.publish',
attachment: {
name: 'name',
caption: 'caption',
source: 'picture.jpg',
picture: 'picture.jpg',
description: 'description',
href: 'http://apps.facebook.com/appname'
},
action_links: [
{ text: 'name', href: 'http://apps.facebook.com/appname' }
]
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
</script>
If you however you would like to keep your app in the FBML form, try this code:
<script type="text/javascript">
FB.ui(
{
method: 'stream.publish',
attachment: {
name: 'name',
caption: 'caption',
source: 'picture.jpg',
picture: 'picture.jpg',
description: 'description',
href: 'http://apps.facebook.com/appname/index.php'
},
action_links: [
{ text: 'name', href: 'http://apps.facebook.com/appname/index.php' }
]
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
</script>
You need to understand the difference between Iframe and FBML apps: While Iframe apps make the user stay in the same page all the time, and only the content in the Iframe is changes, FBML application actually move the user from page to page. Because of this, when specifying links in FBML apps, it is important to use the http://apps.facebook.com/appname/page link instead of the http://www.yoursite.com/page link.
Example links:
A link on your site: http://www.yoursite.com/game1.php
Would look like this in an FBML app: http://apps.facebook.com/appname/game1.php
ok Hafiz then try this code.
FB.ui({
method: 'stream.publish',
message:'hello',
attachment: {
name: title,
caption: "I'm running!",
media: [{
type: 'image',
href: 'http://www.yoursite.com/',
src: 'http://www.yoursite.com/images/working.jpeg'
}]
},
action_links: [{
text: 'Get your percentage',
href: 'http://www.yoursite/'
}],
user_message_prompt: 'Tell your friends about Get your percentage:'
});