Skip to content

Add "Change page's cover photo by API" to the cookbook #150

@nbartels

Description

@nbartels

Working with the page API is fun, if you can do things you would normally have to spend much time for. So here is one interesting snippet.

How do I change the cover photo of a page by Graph API.

Solution:
First upload a image to the page and in return you get the new photo id.
Then send a request to the page and use this photo id to set the cover.

In code this looks like:

// step 1
FacebookType ft = 
     client.publish(id + "/photos", 
     FacebookType.class, 
     BinaryAttachment.with("test.jpg",is),
     Parameter.with("message", "description"));

// step 2
client.publish(id, GraphResponse.class, Parameter.with("cover", ft.getId()), Parameter.with("offset_y",0));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions