Objective c 如何将代码转换为目标c进行SMS验证
我想解析twilio url的数据,它将用于 请帮助将以下代码的swift转换为目标:Objective c 如何将代码转换为目标c进行SMS验证,objective-c,twilio,Objective C,Twilio,我想解析twilio url的数据,它将用于 请帮助将以下代码的swift转换为目标: @IBAction func pressedSend(sender: AnyObject) { let code = arc4random_uniform(8999) + 1000 var data = [ "To" : textTo.text as String, "From" : "<replace with you
@IBAction func pressedSend(sender: AnyObject) {
let code = arc4random_uniform(8999) + 1000
var data = [
"To" : textTo.text as String,
"From" : "<replace with your Twilio local number>",
"Body" : String(code) as String
]
var swiftRequest = SwiftRequest()
swiftRequest.post("https://api.twilio.com/2010-04-01/Accounts/ACc4e304c952c972c26699b927422e668953/Messages",
auth: ["username" : "ACc4e304c952c972c26699b927422e668953", "password" : "5ab5312824b1d057dea249668e2c4189"],
data: data,
callback: {err, response, body in
if err == nil {
println("Success: (response)")
} else {
println("Error: (err)")
}
})
}
@iAction func按Send(发件人:任意对象){
设代码=arc4random_均匀(8999)+1000
风险值数据=[
“To”:textTo.text作为字符串,
“从”:“从”,
“正文”:字符串(代码)作为字符串
]
var swiftRequest=swiftRequest()
SWIFTLEST.post(“https://api.twilio.com/2010-04-01/Accounts/ACc4e304c952c972c26699b927422e668953/Messages",
认证:[“用户名”:“ACc4e304c952c972c26699b927422e668953”,“密码”:“5AB5312824B1D057DEA24966E2C4189”,
数据:数据,
回调:{err,response,body in
如果err==nil{
println(“成功:(响应)”)
}否则{
println(“错误:(err)”)
}
})
}
谢谢你的帮助我想应该是这样的。我不太清楚swiftRequest,所以我假设它是您的网络请求类
-(IBAction)pressedSend:(id) sender{
NSInteger code = arc4random_uniform(8999)+1000;
NSDictionary *data = @{@"To":textTo.text, // guessing this is a label?
@"From":"<replace with your Twilio local number>",
@"Body":[NSString stringWithFormat:@"%d",code]
};
SwiftRequest *swiftRequest = [SwiftRequest new];
[swiftRequest Post:@"https://api.twilio.com/2010-04-01/Accounts/ACc4e304c952c972c26699b927422e668953/Messages"
auth:@{@"username" : @"ACc4e304c952c972c26699b927422e668953",
@"password" : @"5ab5312824b1d057dea249668e2c4189"}
callback:(NSerror *error, id response){
if(error != nil){
// has error
}
else{
// has no error
}
}
}];
}//end method
-(iAction)按发送:(id)发送人{
NSInteger代码=ARC4随机统一(8999)+1000;
NSDictionary*data=@{@“To”:textTo.text,//猜这是一个标签吗?
@“从”:“从”,
@“正文”:[NSString stringWithFormat:@“%d”,代码]
};
SwiftRequest*SwiftRequest=[SwiftRequest new];
[捷运快讯:@”https://api.twilio.com/2010-04-01/Accounts/ACc4e304c952c972c26699b927422e668953/Messages"
身份:@{@“用户名”:@“ACc4e304c952c972c26699b927422e668953”,
@“密码”:@“5ab5312824b1d057dea249668e2c4189”}
回调:(N错误*错误,id响应){
如果(错误!=nil){
//有错误
}
否则{
//没有错误
}
}
}];
}//结束方法
我投票决定以主题外的方式结束此问题,因为SO不是一项代码编写服务。对不起,我知道,但我的问题是为了指导您这样做