Search code examples
facebook-graph-apiticker

Could you explain me how i get news tickers from facebook into my app?


In my app. i get user's feed and user's news ticker. With first i have no questions, but with the second i have some troubles. How a can access to the ticker using php?


Solution

  • From my experience the ticker is just a shortened version of a users news feed using "story"

    Here is a sample batch request "with only 1 request" i use to display ticker info from a users news feed.

    user / home https://developers.facebook.com/docs/reference/api/user/#home

    filtering results based on user lists https://developers.facebook.com/docs/reference/fql/stream_filter/

    API Request:

    <?php
    
    $Ticker = $facebook->api('/me/home?fields=id,story%26'.$access_token.'');
    echo '<pre>';
    print_r($Ticker);
    echo '</pre>';
    
    ?>
    

    Batch API Request:

    <?php
    
    $Ticker = '/me/home?fields=id,story%26'.$access_token.'';
    $queries = array(
        array('method' => 'GET', 'relative_url' => ''.$Ticker.'')
    );
    $batchResponse = $facebook->api('?batch='.json_encode($queries), 'POST');
    $MEticker = json_decode($batchResponse[0]['body'], true);
    echo '<pre>';
    print_r($MEticker);
    echo '</pre>';
    
    ?>