🔍 Code Extractor

class SocialRestFeed

Maturity: 50

SocialRestFeed is a SharePoint entity class that represents a social feed containing threads with root posts and response posts, accessible via OData requests using MS-CSOMREST protocol.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/feed/rest.py
Lines:
6 - 20
Complexity:
simple

Purpose

This class provides an interface to interact with SharePoint social feeds through the REST API. It encapsulates a social feed structure that contains an array of threads, where each thread has a root post and associated response posts. This component is specifically designed for use with the MS-CSOMREST protocol and is not available through MS-CSOM. It inherits from the Entity base class and provides access to the underlying SocialFeed data structure through a property accessor.

Source Code

class SocialRestFeed(Entity):
    """
    The SocialRestFeed class specifies a feed, which is an array of thread, each of which specifies a root post
    and an array of response posts. The SocialRestFeed type is available when the protocol client sends an OData
    request to a protocol server using [MS-CSOMREST]. It is not available using [MS-CSOM].
    """

    def __init__(self, context):
        super(SocialRestFeed, self).__init__(
            context, ResourcePath("SP.Social.SocialRestFeed")
        )

    @property
    def social_feed(self):
        return self.properties.get("SocialFeed", SocialFeed())

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

context: The client context object that provides the connection and authentication information needed to communicate with the SharePoint server. This context manages the request/response lifecycle and maintains the session state for API calls.

Return Value

Instantiation returns a SocialRestFeed object that represents a SharePoint social feed entity. The object provides access to the social feed data through the 'social_feed' property, which returns a SocialFeed object containing the feed's threads and posts. If the feed data hasn't been loaded yet, the property returns an empty SocialFeed instance.

Class Interface

Methods

__init__(self, context) -> None

Purpose: Initializes a new SocialRestFeed instance with the provided client context and sets up the resource path for the SharePoint social feed entity

Parameters:

  • context: The client context object that manages the connection to the SharePoint server and handles authentication

Returns: None - constructor initializes the instance

@property social_feed(self) -> SocialFeed property

Purpose: Retrieves the SocialFeed object containing the feed's threads and posts from the loaded properties

Returns: A SocialFeed object containing the feed data with threads, root posts, and replies. Returns an empty SocialFeed instance if the data hasn't been loaded from the server yet

Attributes

Name Type Description Scope
properties dict Inherited from Entity base class. Stores the loaded properties from the SharePoint server, including the 'SocialFeed' data structure instance
context ClientContext Inherited from Entity base class. The client context object used for communication with the SharePoint server instance
resource_path ResourcePath Inherited from Entity base class. The resource path identifying this entity as 'SP.Social.SocialRestFeed' in the SharePoint REST API instance

Dependencies

  • office365

Required Imports

from office365.runtime.paths.resource_path import ResourcePath
from office365.sharepoint.entity import Entity
from office365.sharepoint.social.feed.feed import SocialFeed

Usage Example

from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.social.rest_feed import SocialRestFeed

# Authenticate and create context
ctx = ClientContext('https://yourtenant.sharepoint.com/sites/yoursite')
ctx.with_credentials(user_credentials)

# Create a SocialRestFeed instance
social_rest_feed = SocialRestFeed(ctx)

# Load the feed data from the server
ctx.load(social_rest_feed)
ctx.execute_query()

# Access the social feed data
feed = social_rest_feed.social_feed
for thread in feed.threads:
    print(f"Root post: {thread.root_post.text}")
    for reply in thread.replies:
        print(f"  Reply: {reply.text}")

Best Practices

  • Always ensure the context object is properly authenticated before instantiating SocialRestFeed
  • Call ctx.load() and ctx.execute_query() to fetch the actual feed data from the server before accessing the social_feed property
  • This class is only available when using MS-CSOMREST protocol; do not attempt to use it with MS-CSOM
  • The social_feed property returns an empty SocialFeed object if data hasn't been loaded, so always check if data exists before processing
  • Handle network errors and authentication failures when executing queries against the SharePoint server
  • The class inherits from Entity, so it follows the standard SharePoint entity lifecycle: instantiate, load, execute query, then access properties

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class SocialRestFeedManager 86.4% similar

    SocialRestFeedManager is a REST API manager class for SharePoint social features, enabling operations like creating posts, modifying threads, and consuming feeds on behalf of the current user.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/feed/rest_manager.py
  • class SocialFeed 85.2% similar

    SocialFeed is a data class representing a social media feed containing threads of posts, with metadata about processed items and unread mentions.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/feed/feed.py
  • class SocialRestThread 84.0% similar

    Represents a social thread stored on a SharePoint server, containing a root post and zero or more reply posts, accessible via OData REST API.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/rest_thread.py
  • class SocialThread 70.9% similar

    SocialThread represents a social media thread object containing a root post, replies, actors, and metadata for SharePoint social features.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/thread.py
  • class SocialPost 66.8% similar

    SocialPost is a data class that represents a social media post retrieved from a SharePoint server, encapsulating post content, attachments, overlays, source information, and user engagement data.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/posts/post.py
← Back to Browse