2012-12-09 3 views
1

나는 내 자신의 웹 사이트에이 스크립트 https://github.com/briancray/PHP-URL-Shortener을 사용하려고합니다. 나는 그것이 실제로 사이트 링크를 단축해야 내 웹 사이트의 모든 페이지에이 코드를 추가하면URL Shortening to short actually Page

$shortenedurl = file_get_contents('http://yourdomain.com/shorten.php?longurl=' . urlencode('http://' . $_SERVER['HTTP_HOST'] . '/' . $_SERVER['REQUEST_URI'])); 

: 읽어보기에 그것은 PHP이 여기

프로그램 단축 URL은 다음 코드를 사용하여 알려줍니다. 그러나 그것은 나에게 Link와 Shorten을 보여주지 않을 것입니다.

$shortenedurl = file_get_contents('http://yourdomain.com/shorten.php?longurl=' . urlencode('http://' . $_SERVER['HTTP_HOST'] . '/' . $_SERVER['REQUEST_URI'])); 

만 그것을 단축하고 변수로 저장 것이다 이렇게

답변

1

. 이를 표시하려면 echo을 사용하여 변수의 내용을 표시해야합니다. 이 시도 :

$shortenedurl = file_get_contents('http://yourdomain.com/shorten.php?longurl=' . urlencode('http://' . $_SERVER['HTTP_HOST'] . '/' . $_SERVER['REQUEST_URI'])); 
echo $shortenedurl; 
+0

당신이 내가이 스크립트에 API 키를 추가 할 수도 어떻게 어쩌면 말해 수 당신에게 – karabey

+0

aam1r 대단히 감사합니다? – karabey

+0

@karabey : 무슨 뜻인지 모르겠다. [소스 코드] (http://briancray.com/posts/free-php-url-shortener-script/)를 보면 API 키에 대한 언급이 없습니다. –