Note: This question is not asking how to extract post_id's from the permalink. I'm asking what does the suffix of the permalink
actually means/stands for.
I'm working on an app that pulls facebook photos/statuses.
I use a regex to pull the post_id out of a facebook permalink, which normally looks like this:
https://www.facebook.com/username/posts/post_id
However, from time to time, I notice some permalinks that looks like this:
https://www.facebook.com/username/posts/post_id:0
Question:
What is ":0"? When/why does it occur?
Edit:
Example of facebook posts:
https://www.facebook.com/hehui.lim/posts/10202967332729156
And..
https://www.facebook.com/lengyein/posts/10152174297949341:0
I also noticed that it is possible to have :1, :2, :3.
Finally, after looking for such a pattern in some of the posts on my News Feed, I found something worth sharing.
One of my friend uploaded 4 different pictures (from the BlackBerry Smartphone App) almost at the same time. All four pictures had a separate Permalink and the message with each post was '{friend's name} added a new photos'. That is:
https://www.facebook.com/{friend's username}/posts/p_id:0 //Picture 1
https://www.facebook.com/{friend's username}/posts/p_id:1 //Picture 2
https://www.facebook.com/{friend's username}/posts/p_id:2 //Picture 3
https://www.facebook.com/{friend's username}/posts/p_id:3 //Picture 4
And, Facebook also generated the link:
https://www.facebook.com/{friend's username}/posts/p_id
which was showing all the 4 pictures grouped together and with a message '{friend's name} added 4 new photos.' That is, showing all 4 photos in a single post.
So, I guess Facebook uses it to group together the individual photos added by a user, one by one, within a certain period of time difference.
NOTE: This is not the same if all the four photos are added together at the same time (I've already tried it).
I think I know the answer.
Credits to Rahil Arora who noticed the sequence.
The scenario is as such:
A photo is being pushed from a third party application (Fb, Instagram, iPhone Gallery, etc) onto your Facebook wall by person A.
Person B is connected to person A.
Person B see's this update on his/her news feed. If B clicks hovers/clicks the timestamp, the relative link will be as the scenario in the question, and everything else is as described in Rahil's answer.
I use explode for a similar purpose.
refer to: http://www.php.net/explode
$str = 'https://www.facebook.com/hehui.lim/posts/10202967332729156:0';
$strEx = explode('/', $str, 6);
$strExId = explode(':', $strEx[5], 2);
echo $strExId[0]; // produces 10202967332729156
Array
(
[0] => https:
[1] =>
[2] => www.facebook.com
[3] => hehui.lim
[4] => posts
[5] => 10202967332729156:0
)
Array
(
[0] => 10202967332729156
[1] => 0
)
Related
Right now the Facebook API is returning a URL like this with all post/album images 130x130 pixels in size:
https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xfp1/v/t1.0-9/s130x130/10801504_570625556403546_6496651209845129904_n.jpg?oh=dcf8ab3752522532871d2aaab09b6e7e&oe=54E4402F&gda=1424027679_76464aeeaa5d232b8100d01476af4ec7
How do I retrieve a full (or any bigger size) image based on that URL?
For example this one:
https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xfp1/v/t1.0-9/p417x417/10801504_570625556403546_6496651209845129904_n.jpg?oh=cd2b5cb0d74f7306c098de9f56dc6e27&oe=54E1F4C1&gda=1423830001_e700bfac39039952bfee55b200c158bf
or anything like that?
All the other suggestions of removing s130x130 from the URL, or /v/t1.0-9/, or replacing _s with _n or anything like that aren't valid any more - I've tried them all (try them yourself if you don't believe me). Is there a way to make this happen? Not sure what Facebook guys have changed to disable that...
After a couple of hours searching and pulling my hair out, I found a solution that works for me. In my case I'm pulling posts from {page-id}/posts, but I'm pretty sure this will work for you too, seeing that I used to get larger images using the same approach as you mention.
This is works for me:
bigger_image="https://graph.facebook.com/" + picture_url_from_facebook.match(/_\d+/)[0].slice(1) + "/picture?type=normal";
/_\d+/ matches any substring starting with an underscore (_) followed by any digits (\d matches one digit, \d+ does the digit match over and over until it fails)
match(regex) returns an array with all strings it could find matching the specified regex
we grab the first ([0]) element, as this will be an underscore followed by the ID of the picture in Facebook's database
we slice the string from index 1 to the end, as the underscore is not a part of the ID
we then get a working link from facebook using the graph api without the need for any extra calls (you can use this in for example an img tag directly)
You can see this working in action # this fiddle or this page we did for a client
Thanks to Er Adhish for leading the way to the solution # https://stackoverflow.com/a/27075503/2908761
https://graph.facebook.com/{object_id}/picture?type={thumbnail|album|normal}
Example (using a bogus object_id of 122233334444555):
https://graph.facebook.com/122233334444555/picture?picture?type=large
Make sure object_id is not just the id of an item but it's object_id (which is typically the number following the underscore in the full id).
I got those type values from a helpful facebook response message that said:
"message": "(#100) type must be one of the following values: thumbnail, album, normal"
In place of ?type=... you could do height/width as well:
?width=543&height=543
We are trying to retrieve ALL the posts, with associated comments and images, made to our group in the last year. I've tried using GraphAPI to do this but pagination means I have to get data, then copy the "next" link, and run again. Unfortunately, this means a LOT of work, since there are over 2 million posts to the group.
Does ANYONE know of a way to do this without spending a few days clicking? Also consider that the group has 4000+ members and is growing everyday, with, on average, about 1000 posts a DAY at the moment.
For the curious, the PLAN is to cull the herd...
I am HOPELESS at programming and have recently started learning Python...
I made it like this, you'll probably have to iterate through all posts until data is empty. Note this is Python 2.x version.
from facepy import GraphAPI
import json
group_id = "YOUR_GROUP_ID"
access_token = "YOUR_ACCESS_TOKEN"
graph = GraphAPI(access_token)
# https://facepy.readthedocs.org/en/latest/usage/graph-api.html
data = graph.get(group_id + "/feed", page=False, retry=3, limit=800)
with open('content.json', 'w') as outfile:
json.dump(data, outfile, indent = 4)
I've just found, and used #dfdfdf 's solution, which is great!
You can generalize it to download from multiple pages of a feed, rather than just the first one, like so:
from facepy import GraphAPI
import json
group_id = "\YOUR_GROUP_ID"
access_token = "YOUR_ACCESS_TOKEN"
graph = GraphAPI(access_token)
pages = graph.get(group_id + "/feed", page=True, retry=3, limit=1000)
i = 0
for p in pages:
print 'Downloading page', i
with open('content%i.json' % i, 'w') as outfile:
json.dump(p, outfile, indent = 4)
i += 1
I am using facebook graph api to search the keywords, like as follows
https://graph.facebook.com/search?q='test'&limit=60&access_token=(myAccessToken)
Which works fine and returns the data correctly.
But I want to search with multiple keywords (Eg . I need the post which contains the words 'test' or 'date')
I tried in the following way, which is working but returns the array which contains the words test and date. It doesn't return the results of individual words.
https://graph.facebook.com/search?q=test|date&limit=60&access_token=
(myAccessToken)
Is it possible to implement graph api search with multiple keywords in "OR" condition?
If so explain how?
I know that is one year later but did you manage to find a solution? I've tried with different methods, like putting " | " character, but nothing works. I'm wondering to give it a try to batch request, passing on each query each keyword that I'm interested in and loop later through the responses to filter repeated results.
You can use FQL. For example if you have two different artists pages and you want to get information about both:
$fql = 'SELECT name,fan_count,page_id,hometown,record_label from page WHERE name="Rihanna" OR name="Jay z" LIMIT 2';
$ret_obj = $facebook->api(array('method' => 'fql.query','query' => $fql));
foreach( $ret_obj as $var)
{
var_dump($var);
}
This code will return you an array that has the required information about both artists.
I'm very new to Meteor, so this question might sound awkward. I'm trying to display a list of all posts
Posts = new Meteor.Collection('posts');
and then in Meteor.publish('posts', ...)
return Posts.find();
and show a number of comments related to each of those posts. Comments are stored in a separate collection
Comments = new Meteor.Collection('comments')
I don't want users to download all comments from the database just to find out comments count for each of the posts - I'm not displaying them here. So
Meteor.publish('comments', function(){
return Comments.find();
})
is not an option.
I know I could denormalize the data and store commentsCount in Post documents. But is there any other way to do this? I'd like it to be observable - or rather live updating, of course. I know how to do it when displaying a single post, but I don't know how to do it for the whole list.
did you know that you can add parameters to your publish function?
you could have something like
Meteor.publish('comments', function(post){
return Comments.find({postId: post._id});
})
this way you get only the comments for one post at a time.
Hope this was what you were looking for
If you're just looking for the number of comments I think you can simply use:
{{commentsCount}}
So an example would be something like:
<h1>Post Title</h1>
<p>{{commentsCount}} comments</p>
Make sure that is used within a post template though or else it won't know which comments it should be counting for.
According to the SSO documentation for IA these attributes should be available (I'm guessing a bit at the attributes URI):
First Name (http://axschema.org/namePerson/first)
Last Name (http://axschema.org/namePerson/last)
Realm Id (http://axschema.org/intuit/realmId)
Reviewing the query string passed during stage 3 of the open id request, here are the attributes present:
openid.alias3.type.alias1 => http://axschema.org/namePerson
openid.alias3.value.alias1 => Full Name
openid.alias3.type.alias2 => http://axschema.org/contact/email
openid.alias3.value.alias2 => email#test.com
Bug, error in the documentation, or loose nut behind the keyboard?
Two problems here, the first problem is in my haste of cut and paste coding I was only requesting the full name and email. I revised the code to request first name, last name, and realm id. Now first name and last name come through fine. However, it took a big of poking around to get to the bottom of the realm id issue. First, the documentation did not give a clear answer on the attribute uri; however, I was able to find a clear answer on this thread https://idnforums.intuit.com/textthread.aspx?catid=69&threadid=16954. Paul Jackson gives a clear idea what is going on here:
The attribute for realm id is http://axschema.org/intuit/realmId
Sometimes the attribute does not come through
I put together a technique based on his suggestion in this thread. Basically, if the realm id does not come through then I'll parse it from the referring url which has it in the query string as realmId. Clearly, this is brittle but provides a "working" solution for now.
Here is a code snippet you can use during stage 3 of the handshake.
_realmId = fetch.GetAttributeValue(OpenId.IntuitWellKnownRealmId);
if (_realmId == null && httpRequest.UrlReferrer != null)
{
var url = httpRequest.UrlReferrer.ToString();
var i = url.IndexOf('?');
if (i != -1)
{
var querystring = url.Substring(i);
_realmId = System.Web.HttpUtility.ParseQueryString(querystring)["realmId"];
}
}
I take zero credit for this solution, Paul already had it figured out. Just posting here to help anyone searching on this problem.