Sunday, 28 May 2017

I am getting message: '(#100) No matching user found'

I am getting an error on the node.js console when sending a generic message.I'm able to send regular text message but I'm having a problem with generic message..

   { error: 
  { message: '(#100) No matching user found',
    type: 'OAuthException',
    code: 100,
    fbtrace_id: 'BLguK1o+VsH' } } } 

function which sends the generic message.

function sendGenericMessage(recipientId, news) {
var messageData = {
    recipient: {
        id: recipientId
    },
    message: {
        attachment: {
            type: "template",
            payload: {
                template_type: "generic",
                elements: []
            }
        }
    }

}

for (var counter = 0; counter < 2; counter++) {
    messageData.message.attachment.payload.elements.push({
        title: news.articles[counter].title,
        subtitle: news.articles[counter].description,
        item_url: news.articles[counter].url,
        image_url: news.articles[counter].urlToImage,
        buttons: [{
            type: "web_url",
            url: news.articles[counter].url,
            title: "Open Web URL"
        }, {
            type: "postback",
            title: "Call Postback",
            payload: "Payload for " + (counter + 1) + "bubble",
        }],
    });
};

console.log("Generic message ==== " + messageData)

callSendAPI(messageData);}

Logs :

 '{"recipient":{"id":"*****"},
  "message":{"attachment":{"type":"template","payload":{"template_type":"generic","elements":[{"title":"Kashmir \'human shield\' row: Dirty war has to be fought with innovative ways, Army Chief Bipin Rawat says - Times of India","subtitle":"He said armed forces have the right of self defence and Major Gogoi could have opted for firing at the crowd but he chose not to resort to it. Gogoi, who had tied a man to an Army jeep and used him as a human shield from stone throwers last month was criticised by many sections.","item_url":"http://timesofindia.indiatimes.com/india/kashmir-human-shield-row-dirty-war-has-to-be-fought-with-innovative-ways-army-chief-rawat-says/articleshow/58880274.cms","image_url":"http://timesofindia.indiatimes.com/photo/msid-58880318/58880318.jpg?110201","buttons":[{"type":"web_url","url":"http://timesofindia.indiatimes.com/india/kashmir-human-shield-row-dirty-war-has-to-be-fought-with-innovative-ways-army-chief-rawat-says/articleshow/58880274.cms","title":"Open Web URL"},{"type":"postback","title":"Call Postback","payload":"Payload for 1bubble"}]},{"title":"Defying shutdown call, hundreds of Kashmiri youth appear for Army exam - Times of India","subtitle":"A day after Hizbul Mujahideen terrorist Sabzar Bhat was killed, 799 Kashmiri young men participated in the Army recruitment examination amid separatists\' shutdown call. The Army conducted the entrance examination for the post of Junior Commissioned Officers and other associated ranks.","item_url":"http://timesofindia.indiatimes.com/india/defying-shutdown-call-hundreds-kashmiri-youth-appear-for-army-exam/articleshow/58879931.cms","image_url":"http://timesofindia.indiatimes.com/photo/msid-58879922/58879922.jpg?80338","buttons":[{"type":"web_url","url":"http://timesofindia.indiatimes.com/india/defying-shutdown-call-hundreds-kashmiri-youth-appear-for-army-exam/articleshow/58879931.cms","title":"Open Web URL"},{"type":"postback","title":"Call Postback","payload":"Payload for 2bubble"}]}]}}}}',

API call function:

function getTopNews(recipientId){

var form = {};
var url = 'https://newsapi.org/v1/articles?source=the-times-of-india&sortBy=top&apiKey=*****'

request.get({url: url, form: form, headers: ''}, recipientId, function (e, r, b) {
    //callback body
    if (! e && r.statusCode == 200){
        var body = JSON.parse(b);
        console.log(body);
        console.log("----CHECK-----"+ recipientId)
        sendGenericMessage(recipientId, body);
    }else{
        console.error("Unable to receive the news");
        console.error(r);
        console.error(e);
    }

})

}



via Kamalnrf

No comments:

Post a Comment