Unknown path components - javascript

I try to post a "watch" action but I've always this error:
Error occured
Type: OAuthException
Message: Unknown path components: /MyAppName:watch
This is my JS function:
function postWatch()
{
FB.api('/me/MyAppName:watch' +
'?video=http//myLink.com','post',
function(response) {
var msg = 'Error occured';
if (!response || response.error) {
if (response.error) {
msg += "\n\nType: "+response.error.type+"\n\nMessage: "+response.error.message;
}
alert(msg);
}
else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
This is my og:tag
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# video: http://ogp.me/ns/video#">
<meta property="fb:app_id" content="MyAppID" />
<meta property="og:title" content="MyTitle" />
<meta property="og:image" content="http://MyUrlImage.com" />
<meta property="og:description" content="MyDescription" />
<meta property="og:url" content="MyLink.com">
<meta property="og:site_name" content="MySiteName" />
<meta property="og:type" content="video.movie" />
Any ideas ?
Thanks ;)
PS: Sorry for my poor english, I'm french ;)
Regards

For built-in actions the syntax is different. Use video.watches

Actually for your own actions/objects you could use the next syntax:
var params = {};
params['video'] = 'http://example.com/myvideo.html';
FB.api('me/mynamespace:watch','post',params,function(response){
console.log(response);
});
This will actually publish on your wall the action with the object, if your user has provided the publish_actions permission.
For the permissions thing you would probably want to make sure you have the permission, so your check should look something like this:
FB.api('me/permissions','get',function(response){
if (response.data[0].publish_actions){
//do your magic
}
});

Related

How to build and display Consent Pane PLAID with PHP

i want to integrate PLAID system on my project based Laravel framework. Currently i'm developing on step to display Consent Pane PLAID from this doc PLAID LINK DOC. I'm using the javascript code. but i still failed to integrate it. here is my code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Plaid</title>
<script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script>
</head>
<body >
plaid
</body>
<script>
const handler = Plaid.create({
token: 'link-sandbox-xxx',
onSuccess: (public_token, metadata) => {
console.debug("onSuccess");
console.log('public_token: ' + public_token);
console.log('account ID: ' + metadata.account_id);
},
onLoad: () => {
console.debug("onLoad");
},
onExit: (err, metadata) => {
console.debug("onExit");
console.log('metadata ' + metadata);
},
onEvent: (eventName, metadata) => {
console.debug("onEvent");
},
receivedRedirectUri: "https://domainname.com/plaid",
});
handler.open();
</script>
</html>
Display error
POST https://sandbox.plaid.com/link/workflow/start 400 (Bad Request)
Error: oauth uri does not contain a valid oauth_state_id query parameter.
i already added new URL my API menu on PLAID Dashboard but still display this error.
Please help. How do i able to integrate that on my laravel?
The receivedRedirectUri should not be set when initializing Link for the first time. It is used when initializing Link for the second time, after returning from the OAuth redirect.

Uncaught (in promise) Error: 'args.method' must be a non-empty string

When trying to connect the metamask wallet with my local site i am getting this error
I am Using the eth_requestAccounts methord but getting the down err
inpage.js:8 Uncaught (in promise) Error: 'args.method' must be a non-empty string.
at o (inpage.js:8:31826)
at Object.invalidRequest (inpage.js:8:32276)
at l.request (inpage.js:1:37391)
at HTMLButtonElement.Connect (index.js:13:27)
this was the error being Printed on MY console
// HOW TO CONNECT YOUR METAMASK TO YOUR FRONTEND
const button = document.getElementById("ConnectButton");
//button.addEventListener('click',connect);
if (button) {
console.log("button successfully imported");
} else {
console.log("BUtton is not imported");
}
const Connect = async () => {
if (typeof window.ethereum !== "undefined") {
await window.ethereum.request({ methord: "eth_requestAccounts" });
button.innerHTML = "Connected";
} else {
button.innerHTML = "Pls install metamask";
}
};
button.addEventListener("click", Connect);
MY index.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FUND ME</title>
</head>
<body>
<h1>HELLO WORLD
</h1>
<button id="ConnectButton">Connect</button>
<script src="index.js"></script>
</body>
</html>
MY index.html
It might likely be a typo error. You have methord instead of method

displaying api response on html page

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>JSON Test</title>
</head>
<body>
<h1>Hello World</h1>
<div id="myData"></div>
<script>
fetch('http://localhost:3000/api/product/1234567')
.then(function (response) {
return response.json();
})
.then(function (data) {
appendData(data);
})
.catch(function (err) {
console.log('error: ' + err);
});
function appendData(data) {
console.log(data)
var mainContainer = document.getElementById("myData");
for (let key in data) {
var div = document.createElement("div");
div.innerHTML = 'name: ' + data[key] + 'label' + data[key];
mainContainer.appendChild(div);
}
}
</script>
</body>
</html>
Trying to fetch the json response and display it on html page. It's giving me an error: SyntaxError: Unexpected end of JSON input. I guess I'm here to maybe get some help on how to fix this and why this is happening. Thank you.
edit:
The response I get on my console :
{
product: 1234567,
name: 'TV',
salePrice: 149.99
}
The major reason is your response is not in the JSON format, which could be because of getting some non-json format response. Please post the sample JSON response format to understand better.

window.onerror doesnt work with Angular 5

In my Angular app I want to send me error details to my spring endpoint when cricital angular error/bundle error occurs - Angular errors are catched by handleErrors.
So I heard about window.onerror function, so I added this in my index.html file:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Frontend</title>
<base href="/">
<script type="text/javascript">
window.onerror = function (msg, url, lineNo, columnNo, error) {
var string = msg.toLowerCase();
var substring = "script error";
var message = [
'Message: ' + msg,
'URL: ' + url,
'Line: ' + lineNo,
'Column: ' + columnNo,
'Error object: ' + JSON.stringify(error)
].join(' - ');
alert(message);
};
</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<app-root></app-root>
</body>
</html>
Later I want send error data to server, but now I'm just testing it.
And when I specially create error which occurs an Angular compile error I have no alert, just failed to compile
or blank page with get
and looks like onerror doesnt catch it.
Angular provides a common method to handle Error. What you should do is to create a class implements ErrorHandler:
import { ErrorHandler } from '#angular/core';
export class AppGlobalErrorhandler implements ErrorHandler {
handleError(error) {
console.warn("customize catch execption:"+error);
}
}
Then, in app.module.ts, you tell Angular to use our Custom Error Handler, configing in providers:
providers: [
// ...
{
provide: ErrorHandler,
useClass: AppGlobalErrorhandler
}
]
Reference:https://golb.hplar.ch/2018/10/global-errorhandler-angular.html

How can I correct this facebook error?

I have a small facebook application where I want to publish a swf file to a user's wall and my wall.I have got this code so far.However, I am getting an error when I click on Click to share..How do I sort this out?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="../JQuery/JQuery.js"></script>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
function publishStream(targetId, name, links, picture, source, userName,message) {
FB.ui(
{
method: 'feed',
to: targetId,
name: name,
link: links,
picture: picture,
source: source, // The URL of a media file (e.g., a SWF or video file) attached to this post
caption: 'Shared by '+userName,
actions: {name: 'Try App', link: links},
message: message
},
function(response){
if (response && response.post_id) {
//alert('Post was published.');
} else {
// alert('Post was not published.');
}
});
}
</script>
</head>
<body>
<p onclick="publishStream('id', 'name', 'http://t2.gstatic.com/images?q=tbn:ANd9GcSclvwUe23dKnjge54JJH6kQM-8iyTRBT_N5-TCWojVmcD0bTi8YQ', 'http://t2.gstatic.com/images?q=tbn:ANd9GcSclvwUe23dKnjge54JJH6kQM-8iyTRBT_N5-TCWojVmcD0bTi8YQ', 'http://t2.gstatic.com/images?q=tbn:ANd9GcSclvwUe23dKnjge54JJH6kQM-8iyTRBT_N5-TCWojVmcD0bTi8YQ','username','Hello') ">Click to share</p>
</body>
</html>
The error is
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.
The comment from Igy above is most likely correct. Under your applications advanced settings try disabling the stream post URL security option. This option forces you to essentially keep your links within your application so external references will fail.

Categories

Resources