Facebook Messenger bot不向发件人发送邮件

时间:2017-01-19 20:45:02

标签: php facebook facebook-graph-api curl bots

我正在关注此Tutorial以使用php创建一个Facebook Messenger bot

一切正常,但发件人没有收到我的留言。

有我的代码

extension String {
    public func separate(withChar char : String) -> [String]{
    var word : String = ""
    var words : [String] = [String]()
    for chararacter in self.characters {
        if String(chararacter) == char && word != "" {
            words.append(word)
            word = char
        }else {
            word += String(chararacter)
        }
    }
    words.append(word)
    return words
}

}

   func textViewDidChange(_ textView: UITextView) {
        textView.attributedText = resolveHashTags(text: textView.text)
        textView.linkTextAttributes = [NSForegroundColorAttributeName : UIColor.red]
    }

我可以收到该消息并看到它,但是用户没有收到我的消息。

2 个答案:

答案 0 :(得分:1)

通过在//执行请求

之前添加以下代码行来解决此问题

echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/webupd8team-java-$(lsb_release -cs).list && \
    echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
    apt-get update && \
    apt-get install -y --allow-unauthenticated oracle-java8-installer && \
    apt install -y oracle-java8-set-default

希望它有所帮助。

答案 1 :(得分:0)

 $jsonData = '{
    "messaging_type": "RESPONSE",
    "recipient":{
        "id": "' . $sender . '"
    }, 
    "message":{
        "text": "teste web"
    }
}';
$s="";
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);
//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
//Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$ret = curl_exec($ch);