1

我正在使用以下代码成功访问 tagthe.net API,但现在不起作用:

$content = "some content";
// Build the URL
$url = "http://tagthe.net/api/?text=".urlencode($content)."&view=json";
$result = json_decode(request_get($url));
$seeds = @$result->memes[0]->dimensions->topic;

我提出请求的功能是:

function request_get($url) {
            $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; 
            $headers[] = 'Connection: Keep-Alive'; 
            $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; 
            $user_agent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)';
            $referer = 'http://domain/'.rand(1,100000);

            $process = curl_init($url); 
            curl_setopt($process, CURLOPT_HTTPHEADER, $headers); 
            curl_setopt($process, CURLOPT_HEADER, 0); 
            curl_setopt($process, CURLOPT_USERAGENT, $user_agent); 
            curl_setopt($process, CURLOPT_ENCODING , 'gzip'); 
            curl_setopt($process, CURLOPT_TIMEOUT, 30);  
            curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); 
            curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
            $return = curl_exec($process);

            // Check for possible errors
            if ($return === false) {
                log_error(curl_error($process) . ', Url: ' . $url);
            }

            curl_close($process); 
            return $return;
        }

当我执行代码以获取建议的标签时,我得到空结果和以下 cURL 错误:

无法连接到主机,网址: http ://tagthe.net/api/?text=some+content&view=json

在此问题之前,我已成功访问并获取标签列表。我做错了什么?任何建议或想法将不胜感激。也许服务改变了?我搜索但没有发现任何关于它的通知。

4

0 回答 0