FB feed dialog post to page that is not liked by user - facebook-javascript-sdk

This is related to the following question, but I think something has changed since that issue was resolved: How can I use the Feed Dialog to post on a Facebook Fan Page wall not liked by the user?
I am getting the same error message:
An invalid target was specified: 92586461482. The target must be a page, event, or user that the actor can post on the wall of.
The answer that was provided by DMCS was a link to a bug on FB: https://developers.facebook.com/bugs/407033842673075 where a FB developer said "You can write wall posts to pages, but not post content with attachments. By default, feed dialog publishes content with an attachment. So this is by design and not a bug."
However, as you can see below, I do not have any attachment specified in the parameters and I am still not able to use this code to post to a page that is not liked. I've seen other folks having this same issue as well.
FB.ui({
method: 'feed',
to: '92586461482'
}, function(response) {
console.log(response);
});
Is there a way to pass another parameter that will remove the supposed "default" attachment so this will work for users who do not like the page?

Related

I'm having problems making bunnystream API requests with Vuejs fetch

I need to send a post request to the bunnynet api using fetch in vuejs, for this I need to enter the name of the video in the body part.
I want to name the video with the variable I got from the input section, but I couldn't write it as a body. I can send requests statically, but I need to get the name of the video I will create from outside. I couldn't find a solution, I'm stuck on this, can you please help?
enter image description here
enter image description here
I tried to send the value I received as an object or as a string, unfortunately nothing happens.
body: JSON.stringify({
// your expected POST request payload goes here
title: "My post title",
body: "My post content."
})
it worked, i'm so ignorant

getJson method returns an error using woocommerce JSON API plugin

I'm using woocommerce JSON API to retrieve the data of some products like price, SKU, etc...
The thing is that I get an error using this API. I've installed the plugin succesfully and activated it in the WordPress Dashboard.
I've tried the example given in GitHub exactly as the author says.
Here's my javascript code:
$(document).on('pageinit','#restau' ,function(){
var url = 'http://danielvivancos.com/edu/wordpress/shop/?callback=?';
params = { action: 'woocommerce_json_api', proc:"get_products"};
params.arguments = {token: 1234, per_page: 2, page: 1}
jQuery.getJSON(url,params).done(function (data) {
alert("success");
console.log(data);
console.log(url);
}).error(function(jqXHR, textStatus, errorThrown){
alert(jqXHR.responseText);
});
});
At first it didn't do anything, and I didn't understand what was happening but then I added the .error() function and it threw me an error...
Here http://danielvivancos.com/edu/directebre_app_jquerymobile/ you will find the three alerts displayed when you click on any of the three products.
Hope someone can help me or give me some ideas to solve it.
Thank you all!
The API Almost always returns some kind of error string and error code. The one time when it wouldn't would be if there was a PHP error (Even then it tries to catch the error and return something).
One thing you may need to do is to visit the users settings page, setup your permissions, and then save the settings for that API User. Whenever a new method is added to the API you will have to visit this page and resave it.
Another thing to do is to try and run php tests/get_products.php and see what happens. Most of the API functions have a tests file that you can run from the command line to test the API.
Also, while I am very happy you are using it :) it is still unfinished and in the early stages of development.
It looks like your example is working though?
Could you post a bit more about what error you are getting?
When I click on one of the items, it takes me to a page where a popup shows up with a bunch of HTML, this normally means that your API page is not setup properly (if it is making an api request). You will need to setup the API page ( Just create a wordpress page, or use an existing one) Then in the WooCom menu select JSON Api, and set the API page from the dropdown list. Remember to save.

API Error Code 102 : javascript dialogs with php

API Error Code: 102
API Error Description: Session key invalid or no longer valid
Error Message: Iframe dialogs must be called with a session key
I get this funny message when calling a fb dialog to post to a friends wall in my new app. The same code is working for other apps. This suddenly stopped working. When i specifically dont set iframe, a weird pop up now pops up now. As browsers block pop ups it doesnt turn up.
Also auto posting directly is not working even when user permits. My app is not unresricted also. Any one has any idea ??
I've had this error, when calling dialog without user interaction. For example when both 'document ready' and 'FB js-sdk loaded events' are fired. When i called the dialog with same function, parameters, on same page but in reaction on user mouse click - it worked.
If this is similiar to what you have, here is the solution:
FB.getLoginStatus(function(response) {
if (response.authResponse) {
//call dialog here
}
});

Facebook Connect: User has logged in and given permissions, now what?

So i've been trying to get FB Connect working on my site, simply for login and authentication, using the Javascript SDK and following the code at:
https://developers.facebook.com/docs/guides/web/
So the button appears, i click it, a dialog pops up, i click that, presumably my site now has permission to know who i am...
Then what? The guide goes on to saying all the stuff I can access through the Facebook API, all the cool things about permissions, but presumably i need the user's ID or access token or something to get at this stuff. How is that given to me? left as a attribute on one of the elements? Left in a Javascript variable somewhere? Given as an argument to some callback? Thrown high into the heavens for me to receive via satellite downlink?
This is probably incredibly simple, but for the life of me i have not been able to figure it out. Facebook's tutorials have failed me, and so has Google. I want to get this in the Javascript, so I can immediately fill in form-data using the user's Facebook name, put a picture, etc. etc., and presumably send this all back to the server so the server can validate with Facebook that the data is real.
I'm assuming you're using the Login button? https://developers.facebook.com/docs/reference/plugins/login/
If you simply want form info, check out the registration plugin - https://developers.facebook.com/docs/plugins/registration/
However, to answer your question, make an API call to /me. For example:
FB.api('/me', function(user) {
if(user != null) {
// The user object now contains info about the logged in user
}
});
You should subscribe to the auth.login event and wrap the above API call in the successful response, i.e.:
FB.Event.subscribe('auth.login', function() {
// JS to run if when the user logs in, for example, the code snippet above
});

Can I "add friend" with Facebook's API?

Does their API allow my Facebook-connected user to add a friend?
No. Adding friends is not possible through the API.
However you can direct users to http://www.facebook.com/addfriend.php?id=[USER UID]
Where [USER UID] is a valid facebook user id.
Good luck!
I spent a great deal of time looking, and finally came accross a very simple solution.
Using the Facebook Javascript API you can do a friend request with:
<script>
FB.ui(
{
method: 'friends.add',
id: fbid // assuming you set this variable previously...
},
function(param){
console.log(param);
// If they cancel params will show:
// {action:false, ...}
// and if they send the friend request it'll have:
// {action:true, ...}
// and if they closed the pop-up window then:
// param is undefined
}
);
</script>
The callback script can then simply performs an ajax call to your server where
you save info about the action, if needed.
You can test this by using the javascript console app on Facebook:
http://developers.facebook.com/tools/console
Paste in the script above, including the tags, or click the "Examples"
button on the bottom of the text area and find the "fb.ui — friends.add" example.
https://developers.facebook.com/docs/reference/dialogs/friends/
Here is a Wiki list of the API methods available to you http://wiki.developers.facebook.com/index.php/API#Administrative_Methods
Doesn't look like you can add friends via the API. Note the iPhone facebook app also doesn't have an add friends function, it was written via the API, so that lends more weight to the idea that you can't