apiresponse-80

问题描述:customized api response status error 这篇文章主要介绍了一个有趣的事情,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。

QQ授权登录成功后怎么获取用户的头像和昵称

apiresponse-80的相关图片

中文翻译大意是:自定义api响应状态错误。

拓展:对于API开发者来说,正确的错误描述甚至比仅基于Web浏览器的项目更为重要。做为使用者,咱们也能够经过浏览器消息提示清楚地了解错误以及该怎么解决。但对于API自己来讲,它们是由软件而非人员使用的,所以返回的结果应readablebymachines。这意味着HTTP状态代码就必不可少。

API给每一个请求都会返回一个状态码,请求成功一般是200,或者是以2开头的其余状态码。若是返回错误响应,则该响应不该包含2xx代码。

请求因HTTP状态401失败:Unauthorized 的原因?的相关图片

请求因HTTP状态401失败:Unauthorized 的原因?

先拍照,再点头像,再点头像,点更换头像。

我的应用通过QQ授权成功,但不知道怎么获取用户的信息。

- (void)tencentDidLogin{。

NSLog(@"登陆完成!");。

if (_tencentOAuth.accessToken && 0 != [_tencentOAuth.accessToken length])。

// 记录登录用户的OpenID、Token以及过期时间。

NSLog(@"%@",self.tencentOAuth.accessToken);。

[self.tencentOAuth getUserInfo];//这个方法返回BOOL。

else

NSLog(@"登陆不成功 没有获取accessToken");。

- (void)getUserInfoResponse:(APIResponse*) response{。

NSLog(@"%@--",response);。

* APIResponse用于封装所有请求的返回结果,包括错误码、错误信息、原始返回数据以及返回数据的json格式字典。

*/

@interface APIResponse : NSObject<NSCoding> {。

int _detailRetCode;。

int _retCode;。

int _seq;。

NSString *_errorMsg;。

NSDictionary *_jsonResponse;。

NSString *_message;。

id _userData;。

【API】拿到api数据接口该怎么写到自己的HTML里面!星座运势API!的相关图片

【API】拿到api数据接口该怎么写到自己的HTML里面!星座运势API!

HTTP401错误原因:用户没有访问权限,需要进行身份认证。

任何客户端 ( 例如您的浏览器) ,都需要通过以下循环:从站点的 IP 名称 ( 即您站点的网址-URL, 不带起始的 ‘http://') 获得一个 IP 地址。这个对应关系 ( 即由 IP 名称向 IP 地址转换的对应关系 ) 由域名服务器 (DNSs) 提供。

打开一个 IP 套接字 (socket) 连接到该 IP 地址。通过该套接字写 HTTP 数据流。从Web服务器接受响应的 HTTP 数据流。该数据流包括状态编码, 其值取决于 HTTP 协议 。 解析该数据流得到 状态编码和其他有用信息。

该错误在以上所述的最后一步生成,即当客户端收到 HTTP 状态编码并识别其为 401。浏览器接收到401错误信息之后,进行解释,提供一个对话框用于输入用户名/密码。在完成之后送交服务器。服务器验证之后,在验证通过的情况下把请求的资源送给浏览器,否则可能再送出401错误信息。

扩展资料:

相关错误码:

HTTP 400 - 请求无效;

HTTP 401.1 - 未授权:登录失败;

HTTP 401.2 - 未授权:服务器配置问题导致登录失败;

HTTP 401.3 - ACL 禁止访问资源;

HTTP 401.4 - 未授权:授权被筛选器拒绝;

HTTP 401.5 - 未授权:ISAPI 或 CGI 授权失败。

参考资料来源:百度百科-401错误。

如何用阿里云的API进行身份证识别的相关图片

如何用阿里云的API进行身份证识别

java发一个http请求过去,带上参数就可以了啊,跟我们在浏览器上访问资源是一样的 只是它返回的是json格式的数据而已给你两个方法吧:

public static String do_post(String url, List<NameValuePair> name_value_pair) throws IOException { String body = "{}"; DefaultHttpClient httpclient = new DefaultHttpClient(); try { HttpPost httpost = new HttpPost(url); httpost.setEntity(new UrlEncodedFormEntity(name_value_pair, StandardCharsets.UTF_8)); HttpResponse response = httpclient.execute(httpost); HttpEntity entity = response.getEntity(); body = EntityUtils.toString(entity); } finally { httpclient.getConnectionManager().shutdown(); } return body; } public static String do_get(String url) throws ClientProtocolException, IOException { String body = "{}"; DefaultHttpClient httpclient = new DefaultHttpClient(); try { HttpGet httpget = new HttpGet(url); HttpResponse response = httpclient.execute(httpget); HttpEntity ent发处篡肺诂镀磋僧单吉ity = response.getEntity(); body = EntityUtils.toString(entity); } finally { httpclient.getConnectionManager().shutdown(); } return body; }。

请教关于HTTP响应头的设置

以下内容属于引用复制,但可以回复你的问题:

准备工作:在libs下添加 alicloud-Android-apigateway-sdk-1.0.1.jar,commons-codec-1.10-1.jar。

在build.gradle添加 compile'com.squareup.okhttp3:okhttp:3.4.1'。

在onCreate,或者afterViews初始化API网关。

private void initGatewaySdk() {。

// 初始化API网关

ApiGatewayClient.init(getApplicationContext(), false);。

调用拍照功能

private void getPhotoCard(){。

final String status = Environment.getExternalStorageState();。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {。

requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, CAMERA_REQUEST_CODE);。

if (status.equals(Environment.MEDIA_MOUNTED)) {。

defaultPhotoAddress = PHOTO_DIR + "/" + getPhotoName();。

PreferenceUtils.modifyStringValueInPreferences(CardActivity.this, Preferences.IMAGE_3, defaultPhotoAddress);。

imageUri = Uri.fromFile(new File(defaultPhotoAddress));。

Intent intentPhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//action is capture。

intentPhoto.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);。

startActivityForResult(intentPhoto, CAMERA_REQUEST_CODE);。

} else {

Toast.makeText(CardActivity.this, "没有sd卡", Toast.LENGTH_SHORT).show();。

可以对照片进行裁剪

private void cropImageUri(Uri desUri, int outputX, int outputY, int requestCode){。

Intent intent = new Intent("com.android.camera.action.CROP");。

intent.setDataAndType(desUri, "image/*");。

intent.putExtra("crop", "true");。

intent.putExtra("aspectX", 5);。

intent.putExtra("aspectY", 3);。

intent.putExtra("outputX", outputX);。

intent.putExtra("outputY", outputY);。

intent.putExtra("scale", true);。

intent.putExtra(MediaStore.EXTRA_OUTPUT, desUri);。

intent.putExtra("return-data", false);。

intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());。

intent.putExtra("noFaceDetection", true);。

startActivityForResult(intent, requestCode);。

用base64上传照片

private void trygetCardNum() {。

if (NetworkUtils.isConnectWithTip(this, "您未连接网络,无法获取数据")) {。

LoadingUtil.show(this);。

String imgBase64 = "";。

try {

defaultPhotoAddress = PreferenceUtils.getStringValueInPreferences(this, Preferences.IMAGE_3);。

File file = new File(defaultPhotoAddress);。

byte[] content = new byte[(int) file.length()];。

FileInputStream finputstream = new FileInputStream(file);。

finputstream.read(content);。

finputstream.close();。

imgBase64 = new String(Base64.encodeBase64(content));。

// imgBase64 = Base64Img.Bitmap2StrByBase64(bitmap);。

if(imgBase64!=null||!imgBase64.equals("")){。

PreferenceUtils.modifyStringValueInPreferences(CardActivity.this, Preferences.IMAGE_3, null);。

} catch (IOException e) {。

e.printStackTrace();。

return;

// 获取服务

RpcService rpcService = ApiGatewayClient.getRpcService();。

final ApiRequest apiRequest = new ApiRequest();。

// 设置请求地址、Path及Method。

apiRequest.setAddress("https://dm-51.data.aliyun.com");。

apiRequest.setPath("/rest/160601/ocr/ocr_idcard.json");。

apiRequest.setMethod(HttpMethod.POST);。

// 按照文档设置二进制形式Body,支持设置Query参数、Header参数、Form形式Body。

apiRequest.setStringBody("{\"inputs\":[{\"image\":{\"dataType\":50,\"dataValue\":\""+imgBase64+"\"},\"configure\":{\"dataType\":50,\"dataValue\":\"{\\\"side\\\":\\\"face\\\"}\"}}]}");。

// 设置支持自签等形式的证书,如果服务端证书合法请勿设置该值,仅在开发测试或者非常规场景下设置。

apiRequest.setTrustServerCertificate(true);。

// 设置超时

apiRequest.setTimeout(10000);。

rpcService.call(apiRequest, new ApiResponseCallback() {。

@Override

public void onSuccess(ApiResponse apiResponse) {。

// 处理apiResponse。

LoadingUtil.dismiss();。

String s = apiResponse.getStringBody();。

NumBean result = JSONObject.parseObject(s, NumBean.class);。

String dataValue = result.getOutputs().get(0).getOutputValue().getDataValue();。

DataValueBean dataValueBean = JSONObject.parseObject(dataValue, DataValueBean.class);。

Number = dataValueBean.getNum();。

name = dataValueBean.getName();。

address = dataValueBean.getAddress();。

birth = dataValueBean.getBirth();。

nationality = dataValueBean.getNationality();。

sex = dataValueBean.getSex();。

if(dataValueBean.getError_msg()==null){。

runOnUiThread(new Runnable() {。

public void run() {。

if(Number == null||Number.equals("")||name == null||name.equals("")||address == null||address.equals("")||birth == null||birth.equals("")||sex == null||sex.equals("")){。

Toast.makeText(CardActivity.this, "扫描失败,请重试", Toast.LENGTH_LONG).show();。

}else {

//扫描成功

});

}else {

errString = dataValueBean.getError_msg();。

runOnUiThread(new Runnable() {。

public void run() {。

Toast.makeText(CardActivity.this, "扫描失败,请重试", Toast.LENGTH_LONG).show();。

});

@Override

public void onException(ApiInvokeException e) {。

// 处理异常

LoadingUtil.dismiss();。

runOnUiThread(new Runnable() {。

public void run() {。

Toast.makeText(CardActivity.this, "扫描失败,请重试", Toast.LENGTH_LONG).show();。

});

});

附:

public class NumBean implements Serializable{。

private List<OutputsBean> outputs;。

public List<OutputsBean> getOutputs() {。

return outputs;。

public void setOutputs(List<OutputsBean> outputs) {。

this.outputs = outputs;。

public static class OutputsBean {。

private String outputLabel;。

private OutputMultiBean outputMulti;。

private OutputValueBean outputValue;。

public String getOutputLabel() {。

return outputLabel;。

public void setOutputLabel(String outputLabel) {。

this.outputLabel = outputLabel;。

public OutputMultiBean getOutputMulti() {。

return outputMulti;。

public void setOutputMulti(OutputMultiBean outputMulti) {。

this.outputMulti = outputMulti;。

public OutputValueBean getOutputValue() {。

return outputValue;。

public void setOutputValue(OutputValueBean outputValue) {。

this.outputValue = outputValue;。

public static class OutputMultiBean {。

public static class OutputValueBean {。

private int dataType;。

private String dataValue;。

public int getDataType() {。

return dataType;。

public void setDataType(int dataType) {。

this.dataType = dataType;。

public String getDataValue() {。

return dataValue;。

public void setDataValue(String dataValue) {。

this.dataValue = dataValue;。

public class DataValueBean implements Serializable{。

private String address;。

private String birth;。

private String config_str;。

private String error_msg;。

private String name;。

private String nationality;。

private String num;。

private String request_id;。

private String sex;。

private boolean success;。

public String getAddress() {。

return address;。

public void setAddress(String address) {。

this.address = address;。

public String getBirth() {。

return birth;

public void setBirth(String birth) {。

this.birth = birth;。

public String getConfig_str() {。

return config_str;。

public void setConfig_str(String config_str) {。

this.config_str = config_str;。

public String getError_msg() {。

return error_msg;。

public void setError_msg(String error_msg) {。

this.error_msg = error_msg;。

public String getName() {。

return name;

public void setName(String name) {。

this.name = name;。

public String getNationality() {。

return nationality;。

public void setNationality(String nationality) {。

this.nationality = nationality;。

public String getNum() {。

return num;

public void setNum(String num) {。

this.num = num;。

public String getRequest_id() {。

return request_id;。

public void setRequest_id(String request_id) {。

this.request_id = request_id;。

public String getSex() {。

return sex;

public void setSex(String sex) {。

this.sex = sex;。

public boolean isSuccess() {。

return success;。

public void setSuccess(boolean success) {。

this.success = success;。

在AndroidManifest.xml下添加。

<meta-data android:name="com.alibaba.apigateway.appKey" android:value="" />。

<meta-data android:name="com.alibaba.apigateway.appSecret" android:value="" />。

原文地址:http://www.qianchusai.com/apiresponse-80.html

作文《我长大了》400字,作文《我长大了》400字,开头怎么写

作文《我长大了》400字,作文《我长大了》400字,开头怎么写

写春天的景色500字,写春天景色的作文500字左右

写春天的景色500字,写春天景色的作文500字左右

star-130

star-130

v1/article-323

v1/article-323

理论在线-60,理论在线完整版免费视频直播

理论在线-60,理论在线完整版免费视频直播

教育教学经历中最感动的瞬间,教育教学经历中最感动的瞬间学生

教育教学经历中最感动的瞬间,教育教学经历中最感动的瞬间学生

女生去健身房减肥的正确顺序,女生去健身房减肥的正确顺序是什么

女生去健身房减肥的正确顺序,女生去健身房减肥的正确顺序是什么

母亲生日古文寄语,母亲生日古文寄语怎么写

母亲生日古文寄语,母亲生日古文寄语怎么写

alienquesteve全cg解锁攻略-20

alienquesteve全cg解锁攻略-20

不要给孩子报口才班

不要给孩子报口才班

AI写出的论文怎么改 - 完整修改指南与技巧 论文空格降重:原理、效果与更优策略 | 学术写作指南 文章如何快速清除AI痕迹 - 实用指南与技巧 论文降重结果是重新改了的论文吗?深入解析降重本质 文章清除AI痕迹的技巧 - 让你的内容更自然 大雅论文查重怎么操作 - 完整操作指南教程 论文万字差错率怎么降低 - 学术写作指南 万方论文降重图片:技巧与注意事项 | 学术写作指南 文章检测AI高风险怎么办 - 完整解决方案指南 论文降重专业术语怎么改 - 学术写作技巧指南 论文重复字符数怎么降下来 - 学术写作降重指南 用AI写论文查重率会高吗?AI论文写作与查重率分析专题 头条文章疑似AI生成如何解决 - 专题报道 如何有效降低AIGC内容查重率 - 实用指南 | 复古知识库 毕业论文查重报告怎么降重 - 实用降重技巧与方法 论文表格内的数据怎样降重?实用技巧分享 论文里概念怎么降重?实用技巧与方法详解 AI论文写作指南 - 如何利用人工智能高效完成学术论文 论文附件查重变红怎么办?原因分析与解决方法全解析 十个降低论文查重率的修改窍门 - 学术写作指南 论文降重七种方法 - 有效降低重复率的实用技巧 论文查重重复率怎么计算出来的 - 完整解析与指南 论文附件查重变红怎么办 - 完整解决方案指南 AI写作APP - 智能论文写作与免费查重工具 | 专业学术助手 论文怎么快速检查文中符号错误 - 学术写作实用指南 如何有效降低AI查重率 - 实用技巧与方法指南 论文翻译成什么语言可以降重 - 学术写作指南 论文降重时黄色字体需要改吗?解答与技巧 毕业论文原文重复怎么降重?实用技巧与方法全解析 毕业论文国内外研究怎么降重 - 学术写作指南