2013-06-14 3 views
-1

내 웹 사이트에 계정의 트윗을 표시하고 싶습니다. 문제는 트윗이 나와 원하는 전체 링크 대신 항상 http://t.co/... 형식으로 표시된다는 것입니다.Twitter API 1.1 - 렌더링 twitter의 t.co 링크

the rules of the game are all implemented - local players can play together in this link: http://t.co/Nf7j4TaB 

if you are very curious... then, here is the link to the xodul's section under development: http://t.co/6Zbti36T 

etc... 

와 나는이 트윗이 같이 나타나는 원하는 : 예를 들어

, 내가 얻을

:

the rules of the game are all implemented - local players can play together in this link: http://xodul.com/tests/js/ 

if you are very curious... then, here is the link to the xodul's section under development: http://xodul.com/tests 

etc... 

내가로부터 지시를 따랐습니다 내 응용 프로그램을 만들려면 Simplest PHP example for retrieving user_timeline with Twitter API version 1.1 (여기에서 각 트윗의 텍스트를 얻을 수 있습니다. 링크는 http://t.co/...)

Rendering links in tweet when using Get Statuses API 1.1 (최고 득점 대답 코드,이 링크 대신에, 예를 들어, 하이퍼 링크 "<a target='_blank' href='http://t.co/Nf7j4TaB'>http://t.co/Nf7j4TaB</a>"로 텍스트 "http://t.co/Nf7j4TaB") 나는 트위터의 링크를 렌더링하는 방법에 대한 매우 많은 도움을 주셔서 감사합니다

!

+0

비 허용 대답의 코드를 사용하는 것이 훨씬 쉽다)에 관계없이, 어쩌면을 [ 이 링크] (https://dev.twitter.com/docs/tweet-entities)가 도움이 될 수 있습니다. 그것은 짹짹 엔티티에 관한 것입니다. – Jimbo

+0

다른 사람들보다 짧기 때문에 Rivers의 답을 따랐을 것입니다. –

+0

허용되는 사람이 응용 프로그램을 만드는 방법을 설명하고 너의 열쇠. River의 예를 사용하면 사람들을 @ 트위터로 올바르게 트윗 할 수 없으며 해결 된 다른 많은 문제가 있습니다. 원한다면 자유롭게 사용하십시오. 가장 짧은 해결책이 항상 최선은 아닙니다. 게으른! : p – Jimbo

답변

0
:-) 트위터 단축 버전을 반환에 대한 유일한 해결책

답변 해 주셔서 감사합니다.

제안 된 링크 (https://dev.twitter.com/docs/tweet-entities)에서 JSON을 분석 한 후, 나는 노출 된 문제에 대한 해결책 썼다 :

// ... 
$twitter_data = json_decode($json); // last line of the code in: http://stackoverflow.com/questions/12916539 


// print the tweets, with the full URLs: 
foreach ($twitter_data as $item) { 
    $text = $item->text; 

    foreach ($item->entities->urls as $url) { 
     $text = str_replace($url->url, $url->expanded_url, $text); 
    } 
    echo $text . '<br /><br />'; 

    // optionally, here, the code from: http://stackoverflow.com/questions/15610968/ 
    // can be added, too. 
} 
0

다음 튜토리얼을 통해 이러한 속성을 사용하여 실제 링크를 표시 할 수 있습니다.

Note: In API v1.1, entities will always be included unless you set include_entities to False or 0. 

The urls entity 

An array of URLs extracted from the Tweet text. Each URL entity comes with the following attributes: 

url: The URL that was extracted 
display_url: (only for t.co links) Not a URL but a string to display instead of the URL 
expanded_url: (only for t.co links) The fully resolved URL 
indices: The character positions the URL was extracted from 

https://dev.twitter.com/docs/tweet-entities

0

자바 스크립트 이제 새로운 1.1 API를 사용하지 않고 귀하의 사이트에 트위터 게시물을 얻는 실제로 게시물에 전체 URL이 아닌이 http://goo.gl/JinwJ