php
  • json
  • facebook
  • facebook-graph-api
  • facebook-like
  • 2014-11-16 6 views -3 likes 
    -3

    나는 특정 게시물에 대한 카운트와 같은 페이스 북을 보여주는 다음 코드를 가지고 있습니다. 어떻게 데이터 번호를 가져 와서 웹 사이트에 표시합니까?카운트 데이터와 같은 페이 스북을 구문 분석하고 사이트에 반향하는 방법

    <a href="http://graph.facebook.com/fql?q=SELECT url, total_count FROM link_stat WHERE url='http://gunstons.com/mistakes-when-entering-into-a-sectional-title-scheme/'"></a> 
    

    이 코드가

    { 
        "data": [ 
         { 
         "url": "http://gunstons.com/mistakes-when-entering-into-a-sectional-title-scheme/", 
        "total_count": 2 
         } 
          ] 
    } 
    

    가 어떻게 총 카운트 수와 에코 사이트

    답변

    0
    <?php 
    $contents = file_get_contents("http://graph.facebook.com/fql?q=SELECT url, total_count FROM link_stat WHERE url='http://gunstons.com/mistakes-when-entering-into-a-sectional-title-scheme/'"); //Grab the contents of the link 
    $data = json_decode($contents); //Parse the contents into a dictionary 
    echo $data->data->total_count; //Get the total count 
    ?> 
    

    이 작품 희망에 잡아 않는 생산하는 것입니다!

    +0

    'urlencode (..)'는 GET'q '값이 필요합니다. – SuperSaiyan

    +0

    안녕하세요,이 두 가지 모두 똑같은 숫자를 가져옵니다. – stock777

    0
    <a href="http://graph.facebook.com/fql?q=SELECT url, total_count FROM link_stat WHERE url='http://gunstons.com/mistakes-when-entering-into-a-sectional-title-scheme/'"></a> 
    

    브라우저에 전송되는 HTML에 삽입했다고 가정합니다. 그게 너를 잘 해주지 않을거야. 가장 좋은 점은 사용자가 링크를 클릭하면 브라우저가 해당 페이지를 열고 추악한 JSON을 사용자에게 표시한다는 것입니다.


    나는 서버 측에서 처리하고 싶다고 생각하고 사용자에게 최종 계산을 보냈습니다. 이 경우 다음과 같은 내용이 도움이 될 것입니다.

    <?php 
    
    $yourUrl = "http://graph.facebook.com/fql?q="; 
    
    #URL Encode is necessary! 
    $yourUrl .= urlencode("SELECT url, total_count FROM link_stat WHERE url='http://gunstons.com/mistakes-when-entering-into-a-sectional-title-scheme/'"); 
    
    $v = file_get_contents($yourUrl); 
    $obj = json_decode($v,true); 
    echo $obj["data"][0]["total_count"]; 
    
    ?> 
    
    관련 문제