I have some strange issue, which maybe doesn't relate to coding at all (in which case I apologize).
I'm trying to post on my facebook wall using python, and I use facepy library. Code looks like something like this:
graph = GraphAPI(access_token)
graph.post(
path='me/feed',
message = message)
It posts a message on my wall, but this message is only visible for me. None of my friends can see this. I don't why is this, my app has public activity privacy and manually I can post messages that every one sees.
What can cause this behavior?
Have you tried setting the privacy settings?
Refer to the Facebook API on Privacy here: https://developers.facebook.com/docs/reference/api/privacy-parameter/
Specifically, you will want to use privacy={'value':'EVERYONE'} before posting.
you should include the whole JSON string
"privacy" = '{"value":"EVERYONE|SELF|...etc"}'
Related
I want to remove my own instagram followers without blocking them, using python.
I have seen many, many, many, many instagram python libraries online that allow you to stop or start following a person, but that is not what I'm looking for; I don't want to remove who I am following or start following someone, I want to remove people who are following me.
I looked into the official documentation of Instagram's HTTP API trying to make my own solution, but I couldn't find the documentation of this action under any endpoint ( I assume it should be under /friends/ ).
I vaguely remember some library that used to do this, but I cannot find it. Does anyone know of a good way to achieve this, preferably via passing an inclusion/exclusion list for the followers I want to have as a result?
I found a solution in an old library that does something similar. You can't directly remove followers through most tools, but if you block and then unblock a user, the effect you want is achieved. Example code:
# https://instagram-private-api.readthedocs.io/en/latest/_modules/instagram_private_api/endpoints/friendships.html
import instagramPrivateApi
# ...
# Implement a Client class that inherits FriendshipMixin
api = new Client()
api.friendships_block(uid)
api.friendships_unblock(uid)
Here is the API endPoint for removing a follower https://www.instagram.com/web/friendships/{user_id}/remove_follower/
You can do a post request on this URL with appropriate headers and that can do the job.
I'm using PRAW to create a Reddit bot that submits something once a day. After submitting I want to save the url of the submission and write it to a text file.
url = r.submit(subreddit, submission_title, text=submission_text)
The above returns a Submission object, but I want the actual url. Is there a way to get the url from a Submission object, or do I need to do something else to get the url?
submission.shortlink (previously .short_link) is what you're looking for, if submission.permalink wasn't good enough.
reddit = praw.Reddit("Amos")
submission = reddit.get_submission(submission_id="XYZ")
print submission.permalink
>>> www.reddit.com/r/subreddit/comments/XYZ
I see that #TankorSmash has answered your question already, though I thought I might add some fundamental knowledge for future references:
If you use "dir(object)," you'll be able to see both attributes and methods that pertain to the Reddit API (which you may use to test and see all properties that effect the given object being tested). You can ignore everything that starts with an underscore (most likely).
An example would be:
submissionURL = submission.url
Or you can go straight to source where PRAW is getting its data. The variable names are not set by PRAW, they come from this JSON (linked above).
I'm writing a Django app requesting permission to post on facebook.
I can access authorization and callback, but I can't get the parameter 'code' that facebook needs to continue with oauth.
def connect_fb(request):
return redirect("https://graph.facebook.com/oauth/authorize?"
+"client_id=MY_ID&"
+"redirect_uri=MY_URL"
+"&type=user_agent&display=popup&scope=publish_stream")
def callback_facebook(request):
code=request.REQUEST.get("code")
What's the right way to get 'code' so I can continue the oauth process?
I tried several things but I keep getting None instead of a code.
Thanks
I've used django-facebook-oauth in the past, but if you really want to roll your own solution then I'd suggest just looking through their source.
From just glancing through it, the only thing I can see you doing differently is the
&type=user_agent&display=popup
in the URL. The app I linked you to doesn't appear to do that as far as I can tell.
The problem comes from type=user_agent that is used in javascript authentication, and not here.
Removing it allows to get code as above.
I'm building a face-book style activity stream/wall. Using python/app engine. I have build the activity classes based on the current activity standard being used by face-book, yahoo and the likes. i have a Chanel/api system built that will create the various object messages that live on the wall/activity stream.
Where i can use some help is with some design ideas on how the wall should work. as follows:
I am using a fan out system. When something happens i send a message - making one copy but relating it to all that have subscribed to the channel it is written on. This is all working fine.
My original idea was to then simple use a query to show a wall - a simple get all the messages for a given channel or user. Which is fine.
But now I'm wondering if that is the best way to do it. I'm wondering if as the wall is a historical log that really should show "what has happened recently say last 90 days at the most. And that i will use Ajax to fetch the new messages. Is it better to use the message api i have built to send messages and then use a simple model/class/ to store the messages that form the wall for each user. Almost storing the raw HTML for each post. If each post was stored with its post date, object ref (comment,photo,event) it would be very easy to update/insert new entries in the right places and remove older ones. It would also be easy ajax side to simply listen for a new message. Insert it and continue.
I know their have been a lot of posts re "the wall" & "activity" stream does anyone have any thoughts i if my ideas are correct or off track?
Thanks
This is pretty much exactly what Brett Slatkin was talking about in his 2009 I/O talk. I'd highly recommend watching it for inspiration, and to see how a member of the App Engine team solves this problem.
Also you can check Opensocial API for design and maybe http://github.com/sahid/gosnippets.
In my website, users have the possibility to store links.
During typing the internet address into the designated field I would like to display a suggest/autocomplete box similar to Google Suggest or the Chrome Omnibar.
Example:
User is typing as URL:
http://www.sta
Suggestions which would be displayed:
http://www.staples.com
http://www.starbucks.com
http://www.stackoverflow.com
How can I achieve this while not reinventing the wheel? :)
You could try with
http://google.com/complete/search?output=toolbar&q=keyword
and then parse the xml result.
I did this once before in a Django server. There's two parts - client-side and server-side.
Client side you will have to send out XmlHttpRequests to the server as the user is typing, and then when the information comes back, display it. This part will require a decent amount of javascript, including some tricky parts like callbacks and keypress handlers.
Server side you will have to handle the XmlHttpRequests which will be something that contains what the user has typed so far. Like a url of
www.yoursite.com/suggest?typed=www.sta
and then respond with the suggestions encoded in some way. (I'd recommend JSON-encoding the suggestions.) You also have to actually get the suggestions from your database, this could be just a simple SQL call or something else depending on your framework.
But the server-side part is pretty simple. The client-side part is trickier, I think. I found this article helpful
He's writing things in php, but the client side work is pretty much the same. In particular you might find his CSS helpful.
Yahoo has a good autocomplete control.
They have a sample here..
Obviously this does nothing to help you out in getting the data - but it looks like you have your own source and arent actually looking to get data from Google.
If you want the auto-complete to use date from your own database, you'll need to do the search yourself and update the suggestions using AJAX as users type. For the search part, you might want to look at Lucene.
That control is often called a word wheel. MSDN has a recent walkthrough on writing one with LINQ. There are two critical aspects: deferred execution and lazy evaluation. The article has source code too.