首页 / 帖子
配置非编码的方式给手机app提供上传邮箱、头像等信息的接口用于更改邮箱和头像信息

 需求:drupal7通过配置方式(不编码)提供restful service接口,手机app上传邮箱、头像等信息用于更改个人信息。
现状:通过配置drupal7,http头如下:

GET /userapi/user/12.json HTTP/1.1

Host: 192.168.64.178:8083

Accept: application/json

Cache-Control: no-cache

,可以获取用户的个人信息:

{

  "uid": "12",

  "name": "test1",

  "mail": "abc@163.com",

  "theme": "",

  "signature": "",

  "signature_format": "filtered_html",

  "created": "1459846017",

  "access": "1461028487",

  "login": "1460973388",

  "status": "1",

  "timezone": "Asia/Shanghai",

  "language": "",

  "picture": {

    "fid": "12",

    "uid": "1",

    "filename": "picture-12-1460985953.jpg",

    "uri": "public://pictures/picture-12-1460985953.jpg",

    "filemime": "image/jpeg",

    "filesize": "100982",

    "status": "1",

    "timestamp": "1460985953",

    "rdf_mapping": [],

    "url": "http://192.168.64.178:8083/sites/default/files/pictures/picture-12-1460985953.jpg"

  },

  "init": "dongdong20111989@163.com",

  "data": false,

  "roles": {

    "2": "authenticated user"

  },

}

。更改邮箱信息时,http头:

PUT /userapi/user/12 HTTP/1.1

Host: 192.168.64.178:8083

X-CSRF-TOKEN: iJTSIkT3kLSiMl2qJycHwkUdXFQnFnv3cJsnascuqxo

Accept: application/json

Cache-Control: no-cache

Content-Type: application/x-www-form-urlencoded


mail=kkk%40163.com&current_pass=123456

,可以成功修改mail信息,返回修改结果:

{

  "mail": "kkk@163.com",

  "current_pass": "123456",

  "uid": "12",

  "roles": {

    "2": "authenticated user"

  }

}

,但是我想修改其中的头像picture信息,通过Content-Type: multipart/form-data方式,http头:

PUT /userapi/user/12 HTTP/1.1

Host: 192.168.64.178:8083

X-CSRF-TOKEN: iJTSIkT3kLSiMl2qJycHwkUdXFQnFnv3cJsnascuqxo

Accept: application/json

Cache-Control: no-cache

Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW


----WebKitFormBoundary7MA4YWxkTrZu0gW

Content-Disposition: form-data; name="mail"


lll@163.com

----WebKitFormBoundary7MA4YWxkTrZu0gW

Content-Disposition: form-data; name="current_pass"


123456

----WebKitFormBoundary7MA4YWxkTrZu0gW

Content-Disposition: form-data; name="op"


Save

----WebKitFormBoundary7MA4YWxkTrZu0gW

,上传图片但是修改不成功。跟这个问题类似http://drupal.stackexchange.com/questions/58611/how-to-save-images-using-services-3,谢谢。 


0个答案