Home > Backend Development > PHP Tutorial > 这种如何完整写出来求大神指教

这种如何完整写出来求大神指教

WBOY
Release: 2016-06-23 13:54:42
Original
891 people have browsed it

这种一般是双方约定一个key,然后md5后传过去验证
例:
发送方:
$key='123456789';//双方约定并保密
$time = time();
$token = md5($key.$time);
 file_get_contents("www.baidu.com/api/api.php?time=".$time."&token=".token);

接收方:
$time = $_GET['time'];
$token= $_GET['token'];
$key = '123456789';//与上面保持一样
if( md5($key.$time) == $token )
{ echo "true"; }
else{ echo "false"; }

怎么写服务端和客户端求大神写范例


回复讨论(解决方案)

您不是写好了吗?

实现不了不知道怎么验证 版主大人帮我忙下能加QQ20572326吗

如果 "http://www.baidu.com/api/api.php?time=".$time."&token=".token 不是你噫造的话,那么请遵守人家的规则

我现在不知道怎么让客户调用 和我这里如何设置服务端 和验证能否给我写范例 谢谢了

client.php

$key='123456789';//双方约定并保密$time = time();$token = md5($key.$time);$data = file_get_contents("http://www.baidu.com/api/api.php?time=".$time."&token=".$token);$result = json_decode($data, true);if($result['success']){	echo 'success';}else{	echo 'fail';}
Copy after login


api.php
$time = isset($_GET['time'])? $_GET['time'] : '';$token= isset($_GET['token'])? $_GET['token'] : '';$key = '123456789';//与上面保持一样$ret = array();if(md5($key.$time)==$token){	$ret['success'] = true;}else{	$ret['success'] = false;}header('content-type:application/json;charset=utf8');echo json_encode($ret);
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template