Nexmo SMS with visual foxpro



我无法使用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
我认为

你的代码从来没有工作过。可能你在这里放了一个根本不起作用的版本。无论如何,我认为问题是你没有使用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>

相关内容

  • 没有找到相关文章

最新更新