public function check_in($info) { $url = OAUTH_WEIBO_CHECKIN; $content = unserialize($info['content']); $img = $content['img']; $text = $content['text']; $params = array('access_token' => $info['access_token'], 'poiid' => $info['poi_id'], 'status' => $text, 'public' => 1); $files = array(); if ($img) { $files = array('pic' => array('file' => $img['path'], 'filename' => $img['name'], 'mime' => $img['mime'])); } $data = encodeBody($params, $files); $header = 'Content-type: ' . $data[0]['Content-Type']; $opts = array('http' => array('method' => 'POST', 'header' => $header, 'content' => $data[1])); $context = @stream_context_create($opts); $fp = @fopen($url, 'rb', false, $context); if ($fp) { return TRUE; } return FALSE; }
public function message($info) { $content = unserialize($info['content']); $img = $content['img']; $text = $content['text']; if ($img && FALSE) { $url = OAUTH_QQ_TWEET_IMG; $params = array('access_token' => $info['access_token'], 'openid' => $info['openid'], 'oauth_consumer_key' => $this->client_id, 'content' => $text, 'latitude' => $info['latitude'], 'longitude' => $info['longitude'], 'format' => 'json'); $files = array(); if ($img) { $files = array('pic' => array('file' => $img['path'], 'filename' => $img['name'], 'mime' => $img['mime'])); } $data = encodeBody($params, $files); return TRUE; } else { $data = array('access_token' => $info['access_token'], 'openid' => $info['openid'], 'oauth_consumer_key' => $this->client_id, 'content' => $text, 'latitude' => $info['latitude'], 'longitude' => $info['longitude'], 'format' => 'json'); $url = OAUTH_QQ_TWEET; $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($data))); $context = @stream_context_create($opts); $response = @file_get_contents($url, false, $context); $return = $this->parse_response($response); if ($return['errcode'] > 0) { return FALSE; } return TRUE; } }