I am using cordova-plugin-facebook4 version 1.7.4 for facebook share in my app. I got an error while sharing one post to facebook.
{errorMessage : "Facebook error: {FacebookServiceException: httpResponseCode: -1, facebookErrorCode: 190, facebookErrorType: null, message: Error validating access token: The user has not authorized application XXXXXXXX.}" }
From the facebook docs, I came to know that this error occurs when user de-authorizes my app. So I want to login again and obtain a new access token.
In the Facebook docs, I came to know that facebook sends error code 190 when this error occurs. I am able to see the facebookErrorCode field in my error response.
My problem is I am unable to parse the error response to get the facebook error code. I tried few JSON parse and JSON stringify methods. But nothing worked. I am unable to obtain the error code.
Can anyone help me in parsing the error response and getting the error code ?
UPDATE
Here is my code sample
facebookConnectPlugin.showDialog(
{ method: "share_open_graph",
action: 'og.likes',
object: JSON.stringify({
object:'https://developers.facebook.com/docs/',
})
},
function (response) {
console.log(JSON.stringify(response));
DialogService.showToast('FB_SHARE_SUCCESS', 'Short', 'Bottom');
},
function (response) {
console.log('share failed. ',response);
if(response.errorMessage.facebookErrorCode == 190){
fblogin.then(
function(response){
share();
},
function(error){
//
}
)
}else{
DialogService.showToast('FB_SHARE_FAILED', 'Short', 'Bottom');
}
}
);
I am able to post to facebook if the user authorizes the app for posting.
If the user de-authorizes, I am unable to capture the error code 190.
Related
Im having an issue solving captchas using puppeteer-extra and puppeteer-extra-plgin-recaptcha. Everything was going very smooth and randomly it broke. It is definitely some issue with not returning the captcha token but im not sure how to fix it. Here is some info.
This is my code initializing it
puppeteer.use(
RecaptchaPlugin({
provider: {
id: '2captcha',
token: 'token' // REPLACE THIS WITH YOUR OWN 2CAPTCHA API KEY ⚡
},
visualFeedback: true // colorize reCAPTCHAs (violet = detected, green = solved)
})
)
This is where i call it
await page.solveRecaptchas()
This is the error
PuppeteerExtraPluginRecaptcha: An error occured during "getRecaptchaSolutions": {
_vendor: 'recaptcha',
provider: '2captcha',
id: '97j1ixpkm2h',
requestAt: 2021-07-24T17:26:54.251Z,
error: 'Error: 2captcha error: Missing response data: undefined'
}
If anyone can help it would be greatly appreciated.
I saw many topics about this error but I could not find any solution to mine. I woke up in this morning and served my code and I saw that the error "Unexpected end of Json Input" I changed nothing in my code or versions of my packages. My colleague and I are working on this project and same codes are working well on his computer although we have same packages and versions.
Problem is when I request the server , it response "status 200 ok" but it returns empty "_body" as you see below image.
Here are details of the error :
The sample code is;
console.log(localStorage.getItem("usedURL"));
return new Promise((resolve, reject) => {
let headers = new Headers();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/x-www-form-urlencoded');
this.http.post(localStorage.getItem("usedURL")+"/login", JSON.stringify({ "UserName": credentials.email, "Password": credentials.password }), { headers: headers})
.subscribe(res => {
console.log(res);
resolve(res.json());
}, (err) => {
reject(err);
});
});
However I believe that it is not releated with code. So I tried to clean cache , deleting node modules and re-installing it. Copied all codes from my colleague to my computer but issue has never gone. So anybody has any idea how can I fix this problem ?
Thanks.
Which version of Chrome are you using now? If you using latest version just try downgrade your version :). You're welcome.
If you cannot see the images,
Response;
Response {_body: "", status: 200, ok: true, statusText: "OK", headers: Headers, …}
headers: Headers {_headers: Map(0), _normalizedNames: Map(0)}
ok: true
status: 200
statusText: "OK"
type: 2
url: "http://myapiurl//login"
_body:""
__proto__: Body
Detail of the error;
ERROR SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Response.Body.json (http.js:1091)
at SafeSubscriber._next (account-auth-service.ts:109)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:242)
at SafeSubscriber.next (Subscriber.js:189)
at Subscriber._next (Subscriber.js:129)
at Subscriber.next (Subscriber.js:93)
at XMLHttpRequest.onLoad (http.js:1591)
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.js:4751)
The error you are getting is correct with the response you are getting.
By that I mean that your response body is "", and if you try to JSON.parse("") you will the error you are getting. i.e.,
ERROR SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
So now we found out that the error you are getting is because of the response you are getting. Now we need to know why your API is returning blank string? we don't know since you have not pasted your API login code. Either way you will need to edit your question and add your API login code or create a new question.
I have the following api call in my service:
getData() {
return this.http.post<Object>(this.base_URL + "web_app/login/", JSON.stringify(this.login))
.subscribe(response=>{
console.log(response);
})
The response is an object with two attributes, access_token and Success. I get the following in my console:
{access_token: "...", Success: "Success"}
Success: "Success"
access_token:"..."
When I try to access the access_token attribute, using response.access_token, I get an error. Why is this and how do I fix it? Is the response I'm getting an object? Thank you!
Edit: this is what console gives
enter image description here
As your image shows you are getting the response on console, try accessing it as follows,
.subscribe(response=>{
console.log(response['access_token']);
})
I am getting error uncaught exception: INVALID_TOKEN (intermediate value).forEach is not a function
My code is:
$('#start')
.on('click', function() {
$.getJSON('/twillio-new/token.php', {
name: $('#my-name')
.val(),
identity: $('#my-identity')
.val()
}, function(data) {
// Create the endpoint, and then initialize the main calling app
var endpoint = new Twilio.Endpoint(data.token);
$('#startDiv')
.hide();
$('#callDiv')
.show();
init(endpoint);
});
});
JSON Response:
{"name":"cool
room","identity":"test","token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImN0eSI6InR3aWxpby1mcGE7dj0xIn0.eyJqdGkiOiJlMWE3NTI4YzYyMzdiMGE0MmZlYTc0NDk2MjRlOTFiNC0xNTA3MjEwNjQyIiwiaXNzIjoiZTFhNzUyOGM2MjM3YjBhNDJmZWE3NDQ5NjI0ZTkxYjQiLCJzdWIiOiJBQzVlMTVhMDg5NjVkNWRjM2ZkOWI3YmNiOGMyM2FhMjgxIiwiZXhwIjoxNTA3MjE0MjQyLCJncmFudHMiOnsiaWRlbnRpdHkiOiJ0ZXN0IiwidmlkZW8iOnsicm9vbSI6IiRuYW1lIn19fQ.pvfGEoVripcjq588p8l3QixuVJ4sHBjMdmWa8tspTtY"}
I am generating and getting access token for Twilio Video calling api using this. Please let me know what is wrong with this code?
Which SDK do you have installed? I have seen this error when the code being used was for the incorrect SDK. Looks like the code you are using is for the version 5. Do you have version 5 installed? There have been numerous version based issues with Twilio
I have a JSON store that load data from a PHP script. This script call a Web Service and sometimes it get some errors and I need to capture them and show them in my app.
In my script I print this line when I get an error:
echo '{"success": "false", "error": "'.$res->state->Description.'"}';
In my app I have this code to load the store
targheStore.load({
params: { targa: searchForm.getValues().targa },
callback: function(records, operation, success) {
Ext.getBody().dom.style.cursor = "default";
if(!success){
$("#message2").slideDown('fast');
setTimeout(function() {
$("#message2").slideUp('medium')
}, 2700);
}
}
});
The jQuery code is to show a message "No record found" from the top, but I want to show the error message that I receive from json.
Inside of the operation argument is a request and response object. Use the response object as you would any Ajax response should allow you to handle your messages the way you'd like.
I suggest declaring a globally available handler for processing operation to look for JSON.parse(response.responseText).hasOwnProperty("error") and doing your custom operation in that way.
If you're not using JSONP for communication you can stuff your message in the raw text returned from an HTTP error code (400+) and the {error:} handler in your ajax would be the best way to route errors.