I'm trying to send a link directly into a user message and I write this code:
export default function App() {
const encodeGetParams = (p) =>
Object.entries(p)
.map((kv) => kv.map(encodeURIComponent).join("="))
.join("&");
const handleClick = async () => {
const params = {
app_id: appid,
link:
"http://www.nytimes.com/interactive/2015/04/15/travel/europe-favorite-streets.html",
redirect_uri: uri
};
window.open(
`http://www.facebook.com/dialog/send?${encodeGetParams(params)}`
);
};
return (
<>
<h3>Facebook share text</h3>
<button onClick={handleClick}>Submit</button>
</>
);
}
After I chose the recipient, typing the text and submitting the message I got this error:
I want to use api directly because the sdk does not work on mobile devices.
Reference: https://developers.facebook.com/docs/sharing/reference/send-dialog
encodeURI
on the full URL you are trying to open, makes little sense. Remove that.redirect_uri
as well, as developers.facebook.com/docs/sharing/reference/… explains that is required when using the URL redirect version.