热搜:NVER node 开发 php

求大神帮忙,CI访问restful问题

2024-09-03 10:55:02
求大神帮忙,CI访问restful问题

CI访问restful服务,服务是C#写的,返回的数据格式为json
接口:MemberService。方法login(int a,string b,string c)
我在网上找了些资料,参考上面写了结果报错。
我的代码如下:

$this->load->library('rest',array('server'=>'http://localhost/TeamLoggingWebHost/MemberService.svc/','http_auto'=>'basic'));$param=array('a'=>1,'b=>'hh','c'=>'kk');$result=$this->rest->Get('login',$param,'application/json');


调试后报错
Unable to load the requsted class: rest

这是不是要引用rest的类库。CI框架里面带有rest的类库吗?


回复讨论(解决方案)

你的application/libraries或者system/libraries下没定义rest这个类吧

没有rest 这个类

没有rest 这个类
还是你错吧restful写成了rest 没有这个类的话 那肯定会报错啊

那我如果不用rest类访问,直接用php的 file_get_contents()函数可以访问post方法的服务吗

那我如果不用rest类访问,直接用php的 file_get_contents()函数可以访问post方法的服务吗
应该是可以的

rest client 类库好像是开源的  知道哪里可以下载rest类库吗

我用 file_get_contents()访问 那post提交的参数怎么给

file_get_contents()里面的参数都是在地址后面的但是post提交方式参数不是那样的啊