I want to write an app that parse particular threas on a phpbb forum. So if a thread has 200 pages with 10 posts (that doesn't give you the ability to adjust the post count per page), and has an address like this:
http://www.forum.com/viewtopic.php?t=10&postdays=0&postorder=asc&start=0
where start parameter changes when you navigate to the next pages of the same thread, how do you get the full thread in one go?
I tried:
http://www.forum.com/viewtopic.php?t=10&postdays=0&postorder=asc&start=0&end=2000
but didn't work.
Surely there must be a way to do this I imagine.
If you're parsing, just parse each page, then add up the results in the end. If the forum doesn't have an open API, or any way to display all of the posts on one page, this is what your are going to have to do. Perhaps you could write a recursive function that checks for a 'next page' link or something similar, follows it, then returns all of the data from the pages compiled.
EDIT: looking at example url you gave, have you tried changing the t variable? you said it was 10 posts per page, and that was set to 10, so maybe that's what controls posts per page.
http://www.forum.com/viewtopic.php?t=2000&postdays=0&postorder=asc&start=0
Some super handsome fellow wrote a MOD for this if it is your forum:
http://www.phpbb.com/community/viewtopic.php?f=69&t=1101295
Related
I would like to retrieve all facebook pages liked by a certain user.
The problem is that a /user/likes endpoint returns the list in parts (pagination).
Is there an option to display them all in one page? Facebook docs do not provide such info.
P.S. pagination does not seem to return all the pages. Some of them are missing.
10x.
There is no way to get all pages in one call, you have to use pagination. If pages are missing, you should file a bug.
Btw, you can also try setting a limit:
me/likes?limit=100
...but there is a max value for that, so you can never be sure to get all pages in one call without paging.
So, I've read The Loop and I got the hang of it. (I created a page that lists the 3 most recent posts, a page that shows a page (as opposed to a post), and so on.)
However, it seems silly that, in order to integrate a WordPress blog into an existing site, I'd have to replicate all the different kinds of pages (lists of posts, the posts themselves, pages, etc.)
Is there a generic way of doing this?
The full idea is something like this.
The blog itself (with its ugly default template) is installed at http://blog.example.com.
I want to integrate the blog into an existing site, at the URL http://example.com/blog.
I'm doing a mod_rewrite that forwards the entire query string, e.g. http://blog.example.com/?p=7 gets rewritten to http://example.com/blog?p=7.
Now, in my PHP code at http://example.com/blog, I want to do something like this:
query_posts($_GET);
// display results
wp_reset_query();
That's where I'm stuck. Basically, I want to display exactly what's in the "content" area of a default WordPress template, on my site, according to whatever the query string dictates. Almost as if I were just using an iframe. I would rather not have to parse the query string to figure out whether I have to loop through this or that or turn off the $more global or not, etc.
What am I missing?
Instead, should I be installing the blog at http://example.com/blog and creating a template that mimics the website? This seemed complicated so I didn't go this route, but maybe someone should change my mind.
Appreciate any help, including advice for alternative designs.
Have you considered outputting the blog into a full rss/ outputting the blog as json and then pulling it in that way?
I was looking at websites like http://itstrending.com/, facediggs.com/ and I'm questioning myself how do they extract the most shared topics from facebook? I would like to build a similar widget for my blog. I searched the API but couldn't find anything.
I have no idea, but here are more sites that might provide additional insight into what you're looking for: http://mashable.com/2010/08/18/facebook-search-services/
I found this page which is worth looking at
http://developers.facebook.com/blog/post/323
Half way down this page is a url you can use to check pages on your site, it returns xml with some good stats. Hope this helps.
Running an FQL (Facebook Query Language) query on the link_stat table.
Below: example url to put in your browser and press enter.
It returns xml with true and a count which you can use however you like. This returned 957 last time I tried it. Be carefull using quotes around the url you want to query.
How many facebook shares (total) does stackoverflow have?
Another example with 2 urls
I'm trying to develop web application (php/mysql), sort of blog site where ~10 posts are listed on front page. Only first 4-5 lines of each post are displayed and when user clicks the title it opens new page with full post displayed.
Users will use TinyMCE to post with very limited functionality, so bold, italics, underline, undo/redo and bullet lists only. No HTML view, no links nor images so nothing fancy.
Now, as two displays of the same posts are involved, so the one on front page where part is displayed only, and full version, I'm not sure if I should:
when user submits post I should clear it up with something like HTMLPurifier and store one full version in database. Then cut first 4-5 lines of it, and clear it with HTMLPurifier again to make sure all tags are closed properly. This is to make sure the text I cut doesn't finish with html tag cut in half but rather is valid (x)html properly closed. I would store this shorten front-page version somewhere in database again. So I would have two versions in database ready, full post version and shorten front-page version. Then when someone accesses the site and displays front page with 10 posts, these just need to be read from database and displayed. No need for reading full version, cutting the top of it, making sure all tags are properly closed etc. etc. for all 10 posts every time someone opens the site. The obvious problem would seem that part of content is doubled in database so full version and short version.
Another option I thought about would be when user submits post, clear it up with HTMLPurifier, and store only full version to database. Then when someone accesses the site, cut top part of each blog post, clear it up with HTML purifier (again!) to make sure its all valid, tags are closed etc. and display on front page. Now the problem seems that HTMLPurifier would have to be run and clean every single time when someone accesses the short version of the post, so e.g. 10x for frontage for each visit and so on.
I used HTMLPurifier above as an example only as I'm sure there are other tools douing same thing so please advice if anything else would be more appropriate in my situation. Also I will probably allow users to display more than 10 posts per page.
Ok, I'm sure there is some common pattern to deal with this sort of site and if so please give me an idea of how it should be done as my thought above seems to have many obvious problems. As always your help is much appreciated.
EDIT: I should have clarified.. Its more like an exercise to me and I wanted to learn how this sort of site should be done. Same concept can be implemented on other sites so advertising, forums etc. anything with posting really. For blogging I sure could use something ready but this time I wanted to learn.
When a user posts a blog entry, all you need to do is insert the entire post into the database. Before inserting, you need to escape/clean-up the post so that nothing harmful is inserted.
When viewing the post you will have two type of views - the excerpt and the full. The excerpt will only be the first 4-5 lines of the post. To get this you need to TRUNCATE the post before outputting it. To do that, you need to create a truncate function that will limit the number of words/characters.
You do not need to insert the post twice ( excert and full ) into the database.
For instance:
// Excerpt Post
echo $postTitle;
echo truncate($postBody); // where truncate is the function you used to trim
// Full Post
echo $postTitle;
echo $postBody;
Hope this gets you started!
I have created a widget for my web application. User's getting code and just pasting that code in their website and my widget works on their website something like twitter, digg and other social widgets.
My widget is on the basis of post, for a single post (say postid: 234) I am providing single widget, so anyone can embed the widget on their website.
Now I want to know that where all my widget is posted and for which post? for that I have recorded the URL of the site when my widget start (onload) but the problem arises when someone placed the widget in their blog or website's common sidebar. I am recording URL each time and hence if it's in sidebar of a blog then it's recording URL for every post which is creating duplicates.
can anyone help on this? How should I go so that I have only one single record for a widget on a site?
I think doing something like this is a bit tricky. Here are some ideas that pop to mind
You could for example ask the user to input their site's URL when they get the widget, or the widget could track the domain or subdomain, thus giving less URLs.
Just tracking the domain would obviously be problematic if the actual site is domain.com/sitename/, and there could be more than one site under the domain. In that case, you could attempt to detect the highest common directory. Something like this:
You have multiple URLs like this: domain.com/site/page1, domain.com/site/page2, and so on. Here the highest common directory would be domain.com/site.
I don't think that will always work correctly or provide completely accurate results. For accuracy, I think the best is to just ask the user for the URL when they download the code for the widget.
Edit: new idea - Just generate a unique ID for each user. This could be accomplished by simply taking the current timestamp or something, and hiding it into the code snippet the user is supposed to copy. This way you can track the ID itself and any URLs and domains it appears in can be grouped under it.
If you have an ID which doesn't get a hit in say week or something you could remove it from your database, and that way avoid filling it up with unused IDs.
I agree with Jani regarding a unique id. When you dish out the script you'll then be able to always relate back to that id. You are still going to have duplicates if the user uses the same id over and over, but at least you'll have a way of differentiating one user from another. Another useful advantage is that you are now able to, as Jani said, group by the ID and get a cumulative number for all of the instances where that user used the script & id.