这是什么数据类型(获取请求)bit.ly oauth2 [英] What is this Data Type (Get Request) bit.ly oauth2
本文介绍了这是什么数据类型(获取请求)bit.ly oauth2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
{ "status_code": 200, "status_txt": "OK", "data": { "long_url": "http:\/\/google.com\/", "url": "http:\/\/bit.ly\/17A2GVj", "hash": "17A2GVj", "global_hash": "3j4ir4", "new_hash": 0 } }
我这样做后会得到这样的结果
I get something like this after i do a
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://api-ssl.bitly.com/v3/shorten?access_token=xxx&longUrl=http%3A%2F%2Fgoogle.com%2F',
CURLOPT_USERAGENT => 'Mozilla/4.0'
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
echo $resp;
如何读取hash
推荐答案
$respObj = json_decode($resp);
echo $respObj->data->hash;
json_decode
stdClass
。访问 stdClass
'的成员, - >
。
json_decode
, by default, returns an instance of stdClass
. Access stdClass
' members with ->
.
这篇关于这是什么数据类型(获取请求)bit.ly oauth2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文