草庐IT

page_request

全部标签

swift - 访问 `Request` 主体参数

我正在尝试使用以下代码创建对第三方API的请求链:importVaporfinalclassAPIController:RouteCollection{privateletbaseULR="..."funcboot(router:Router)throws{router.post("login",use:validate)}funcvalidate(_req:Request)throws->Future{//GetthephonenumberoftheuserletphoneNumber=tryreq.content.syncGet(String.self,at:"phone_numb

ios - Swift 项目中的 AFNetorking -- "Error: Request failed: unacceptable content-type: text/html"

我正在将带有CocoaPods的AFNetworking实现到一个Swift项目中。我习惯用Ruby编程,而我对iOS开发还很陌生。Cocoapods很难在我的项目中正常工作,但我现在可以成功访问AFNetworking库。我想做的是用POST命中一个表单并得到一个我可以解析的“text/html”响应,这样我就可以判断它是否保存了。这本身不是API,而是由InfusionSoft生成的表单。用户将输入一个电子邮件地址,我会将其发送到API进行存储。这是我使用的代码:letmanager=AFHTTPRequestOperationManager()varparameters=["in

ios - swift Alamofire : How to validate both a valid request and a valid response code

我们有这个Alamofire错误处理:Alamofire.request(.GET,getUrl("mystuff")).responseData{responseinguardresponse.result.error==nilelse{//Handleerror}}如果无法访问服务器或证书无效等,它会很好地工作。但是如果可以访问服务器但返回404/etc响应代码,则不会触发此错误处理代码。如何将对此用例的支持折叠到此代码中? 最佳答案 response的result属性包含代码,如果它不是nil。否则,您可以获得状态代码。ifl

swift - Alamofire:类型 'Request' 的值没有成员 responseImage?

我正在做一个项目,使用Alamofire+AlamofireImage。我刚刚通过CocoaPods安装了AlamofireImage,但出现了这个错误:Valueoftype'Request'hasnomember'responseImage'对于行:Alamofire.request(.GET,locationURL).responseImage{responseinifletimage=response.result.value{//morecode在所有其他项目中工作正常,Podfile安装行也完全相同。 最佳答案 不确定整

ios - Alamofire 4.0.0 : [String:String] is not convertible to [String : Any] & Request is ambiguous without more context

我正在将Alamofire更新到4.0.0Beta1并将XCode8更新到Beta6。首先,我得到了[String:String]isnotconvertibleto[String:Any]错误代码letparameter=["scope":"\(scope)","client":"\(clientId)"]Alamofire.request(link,withMethod:.POST,parameters:parameter,encoding:.json).responseJSON在我更改后将[String:Any]添加到参数中,错误消失但产生了新错误:Expressiontype'

swift - Vapor PostgreSQL 错误 : invalidSQL ("ERROR: relation\"pages\"already exists\n")

我正在尝试使用Vapor命令还原PostgreSQL数据库:vaporrunprepare--revert-y我把这个放出来了:Runningmist...Areyousureyouwanttorevertthedatabase?y/n>yesRevertingPostRevertedPostRemovingmetadataReversioncomplete如果您想知道,我已尝试多次执行此操作,所以Post类已准备好,但其他类没有。此命令恢复所有模型的表,除了一个(总共有四个)。由于某些原因,“页面”表不会恢复。当我在还原数据库后尝试运行应用程序时,出现此错误:invalidSQL("

ios - CCAvenue: "Error!!! in decrypting application request"

我正在尝试将CCAvenue支付网关集成到我使用swift4开发的iOS应用程序中。我得到了"Error!!!Problemindecryptingapplicationrequest"我已检查给出的答案:https://stackoverflow.com/a/37327122/3548469但我的案子没有运气。这是我从文档中尝试过的privatefuncgettingRsaKey(completion:@escaping(_success:Bool,_object:AnyObject?)->()){letserialQueue=DispatchQueue(label:"serialQ

ios - 收到 MailChimp 错误 "Your request did not include an API key.",即使使用 Alamofire 包含 API key

我正在使用Alamofire向MailChimp发送请求以将用户添加到列表MailChimp的文档说:Thereare2authenticationmethodsfortheAPI:HTTPBasicauthenticationandOAuth2.TheeasiestwaytoauthenticateisusingHTTPBasicauthentication.EnteranystringasyourusernameandsupplyyourAPIKeyasthepassword.我为Alamofire写的请求:letparams:[String:AnyObject]=["email_

swift - 错误 : Extra parameter in request i used Swift 4. 为什么我必须传递类型为 [String : Any]? 的参数

Alamofire.request(APPURL.GetAccounts,method:.post,parameters:transactionData,encoding:JSONEncoding.default,headers:nil).responseJSON{responseDatain}我的问题是限制我只能通过[String:Any]类型的字典的原因是什么?完整代码:classfuncgetAccounts(transactionData:[String:Any]?,withCompletionHandler:@escaping(_response:AnyObject?)->(

iOS 12.2 WKWebview : unable to load local html page after loading https or http url

在应用程序启动时我正在加载https://www.google.com在WKWebView中。应用程序有一个按钮,单击该按钮应用程序将从文档目录加载本地html页面。我使用以下代码加载html页面。letdestPath=NSSearchPathForDirectoriesInDomains(.documentDirectory,.userDomainMask,true)[0]letfileName="Demo.html"letfullDestPath=URL(fileURLWithPath:destPath).appendingPathComponent(fileName)self.