-
Notifications
You must be signed in to change notification settings - Fork 952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for post_args on GraphAPI.put_object method (PR #108 update) #344
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,29 +143,43 @@ def get_all_connections(self, id, connection_name, **args): | |
args = parse_qs(urlparse(next).query) | ||
del args['access_token'] | ||
|
||
def put_object(self, parent_object, connection_name, **data): | ||
def put_object( | ||
self, parent_object, connection_name,post_args=None, **data): | ||
"""Writes the given object to the graph, connected to the given parent. | ||
|
||
For example, | ||
|
||
graph.put_object("me", "feed", message="Hello, world") | ||
|
||
writes "Hello, world" to the active user's wall. Likewise, this | ||
will comment on the first post of the active user's feed: | ||
|
||
feed = graph.get_connections("me", "feed") | ||
post = feed["data"][0] | ||
graph.put_object(post["id"], "comments", message="First!") | ||
|
||
Some parameters that can be sent to the Facebook API can not be passed | ||
to the method using kwargs, for example 'fb:explicitly_shared'. These | ||
needs to be set using the post_args argument dict. If the same key is | ||
used both in the post_arg dict and passed in as a kwarg, the kwarg will | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why were these lines removed? |
||
take precedence. | ||
Usage example, | ||
graph.put_object( | ||
"me", | ||
"nyccookbook:cook", | ||
recipe="http://www.sugarmedia.com/nyccookbook/cookie.html", | ||
post_args={"fb:explicitly_shared": True} | ||
) | ||
will share the object as a post as described in the docs. See | ||
https://developers.facebook.com/docs/opengraph/guides/explicit-sharing/ | ||
for details. | ||
Certain operations require extended permissions. See | ||
https://developers.facebook.com/docs/facebook-login/permissions | ||
for details about permissions. | ||
|
||
""" | ||
assert self.access_token, "Write operations require an access token" | ||
if post_args is None: | ||
post_args = {} | ||
post_args.update(data) | ||
|
||
return self.request( | ||
"{0}/{1}/{2}".format(self.version, parent_object, connection_name), | ||
post_args=data, | ||
post_args=post_args, | ||
method="POST") | ||
|
||
def put_wall_post(self, message, attachment={}, profile_id="me"): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a PEP8 issue on this line that is causing the linting test to fail.