0

我无法使用 foxpro 应用程序发送 Nexmo-SMS。应用程序一直工作到 2017 年 1 月,之后它停止工作。下面给出的是我的申请。它给出了错误消息 404。如果有更正需要程序,请指导我。


mob = '39829374'

mmessage = 'Hi'

username='username'

pwd='password'

mmob1 =ALLTRIM(mmob )

MMOB = '00973'+ALLTRIM(mmob )


From='AMA Motors' 

to = '&mmob'

lcMessage=mmessage

lcNexmo = Textmerge("http://rest.nexmo.com/sms/xml?username=<< m.username >>|password=<< m.pwd >>|from=<< m.from >>|to=<< m.to >>|text=<< m.lcMessage >>")

lcNexmo = Chrtran(m.lcNexmo, '|', Chr(38))

* Message parameters ready


Local loXmlHttp As "Microsoft.XMLHTTP"

loXmlHttp = Newobject( "Microsoft.XMLHTTP" )


loXmlHttp.Open( "POST" , m.lcNexmo, .F. )

loXmlHttp.Send( )


If loXmlHttp.Status = 200

    lcXML = 
StrExtract(loXmlHttp.responsetext,'<messages','</messages>',1,1+4)

    XMLToCursor(m.lcXML,'myresult')

*   browse

Else

    MessageBox( Textmerge( "An error occurred in SMS. Status <<loXmlHttp.STATUS>> (<<loXmlHttp.statustext>>)." ) )

Endif
4

1 回答 1

1

我认为您的代码从未起作用。可能你在这里放了一个根本不起作用的版本。无论如何,我认为问题在于您没有使用https。我稍微编辑了您的代码并发送了 3 条消息(抱歉浪费了您的令牌):

NexmoKey    = '1b37ecc8'
NexmoSecret = 'df183c07'
NexmoNumber = 'AMA Motors'

mob = '39829374'
mmessage = 'Hi'
MMOB = '00973'+ALLTRIM(m.mob )


to = m.mmob
lcMessage = m.mmessage

nexmoURL = Textmerge(;
    "https://rest.nexmo.com/sms/xml?"+;
    "username=<< m.NexmoKey >>|"+;
    "password=<< m.NexmoSecret >>|"+;
    "from=<< m.NexmoNumber >>")

TrySendTTS(m.to,m.lcMessage, m.NexmoUrl)

Procedure TrySendTTS(tcPhone,tcMessage, tcNexmoUrl)
    tcMessage = Strtran(m.tcMessage, '%0A', '%0D%0A')
    lcUrl = Chrtran(;
        Textmerge("<< m.tcNexmoUrl >>|to=<< m.tcPhone >>|text=<< m.tcMessage >>"), '|', Chr(38))

    Local loXmlHttp As "Microsoft.XMLHTTP"
    loXmlHttp = Newobject( "Microsoft.XMLHTTP" )

    loXmlHttp.Open( "POST" , m.lcUrl, .F. )
*   loXmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
    loXmlHttp.Send( )

    ? loXmlHttp.Status = 200
    ? loXmlHttp.responsetext

Endproc

这是我对最新发送的回复:

<?xml version='1.0' encoding='UTF-8' ?>
<mt-submission-response>
    <messages count='1'>
        <message>
            <to>97339829374</to>
            <messageId>0B00000044C5B1ED</messageId>
            <status>0</status>
            <remainingBalance>6.23650000</remainingBalance>
            <messagePrice>0.01740000</messagePrice>
            <network>42601</network>
        </message>
    </messages>
</mt-submission-response>
于 2017-04-11T14:01:48.830 回答