Fetch Blogger Posts based on Order - php

I am fetching data using blogger post API.
https://www.googleapis.com/blogger/v3/blogs/blogId/posts
The results are coming in the newest to oldest format with pagination.I need to fetch with oldest to newest because i need the newest post's time to fetch the data in the next call for the new posts.
How can I use the API with parameters.Currently, i am using the following api call
https://www.googleapis.com/blogger/v3/blogs/posts?startDate2015-10-15T00:00:00+00:00&key=$key

Posts: list only supports ordering by published or updated, not the direction.
orderBy string Sort order applied to results.
Acceptable values are: "published": Order by the date the post was
published "updated": Order by the date the post was last updated
I would recommend you sort them yourself after you get the results back from Google.

Related

How to retrieve date time from mysql in decending order?

I have made a simple blog and trying to retrieve the latest post to the top of the blog. the code i have typed already does the ordering for the specific day however when i try to add a another post the next day it goes to the bottom of the page and the ordering of the latest blog works on that specific day.
So what i want is ,my blog to compare all the dates and then post the latest one right at the top..
many thanks
You should use order by
SELECT * FROM table_name WHERE your_condition ORDER BY your_date_column_name
DESC

FB Graph Api Search, convert FQL query to fetch nearby pages?

I've used the old Facebook SDK where I could do FQL-queries. I want to fetch all nearby places that also has a page attached. And with those results, I want as many columns as possible.
I want to rewrite this function so I can do the same but with the latest Facebook SDK 2.3.
The old way:
SELECT name, type, page_id, hours, categories, about, bio, description, general_info, location, checkins, fan_count, phone, pic_big, website FROM page WHERE page_id IN(SELECT page_id FROM place WHERE distance(latitude, longitude, '37.76', '-122.427') < 1000)
But this doesnt work so well with the new SDK. I've tried the search-method and tried to write different types of queries (in the 'q' parameter) but nothing gets close to this.
As you can see, I want as many columns about the pages as possible.
The closest I've come is this far: https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=search%3Fq%3Dcoffee%26type%3Dpage%26center%3D37.76%2C-122.427%26distance%3D1000&
Does anyone know how I should think/do in order to get this data in the new way?
Have a look at
https://developers.facebook.com/docs/graph-api/reference/page#Reading
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.3#fields
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.3#search
You can specify the desired result fields according to the fields which are available for the respective object.
For example
/search?q=coffee&type=place&center=37.76,-122.427&distance=1000&fields=id,name,hours,category,category_list,about,bio,description,general_info,location,talking_about_count,were_here_count,likes,phone,cover,website
Try it
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=search%3Fq%3Dcoffee%26type%3Dplace%26center%3D37.76%2C-122.427%26distance%3D1000%26fields%3Did%2Cname%2Chours%2Ccategory%2Ccategory_list%2Cabout%2Cbio%2Cdescription%2Cgeneral_info%2Clocation%2Ctalking_about_count%2Cwere_here_count%2Clikes%2Cphone%2Ccover%2Cwebsite
Keep in mind that the fieldnames are not the same from FQl to Graph API.

Graph API, list last posts incl total likes of posts

I'm trying to make a custom-feed from my companies Facebook page to our website. I query the Graph API of Facebook to get this information.
Facebook changed the API a while ago to not include like counts in the normal page query. In the documentation it says to add summary=1 to get the total likes. My query does not return the total_count tho when I query it.
I am omitting my acces_token in the queries because I'm using the API Explorer.
Query I use to get posts:
Raafh/posts?limit=4
trying to add summary=1 does nothing with the query.
I can however do another query which will return the likes and the total count, but not the post info so I can't use it, or I have to use two queries.
Raafh/posts?fields=likes.summary(1).limit(1)
This posts the last like + the total_count.
How can I combine these two in one query?
You can add required fields in comma separated format to get post data like shown in example below.
Raafh/posts?fields=likes.summary(1).limit(1),id,message,from,picture,link,name,caption,description

Eventbrite API PHP, how to do sorting and display one event?

I am using the php library of Eventbrite API to get a list of all events from a user. The default call pulls the list as sorted in ascending order:
$events = $eb_client->user_list_events();
What is the correct syntax to get the list in descending order?
Is there a way to pull only the earliest upcoming event instead of the whole list?
The default display for user_list_events is in ascending order, but you can modify this using the asc_or_desc parameter. Valid options include ‘asc’ or results in ascending order or ‘desc’ or descending order based on event start_date.
If you only want to display one specific event, you can use the event_get method, which uses the id of the requested event to display only that event.

Get the last three statuses and posts on Facebook

I am trying get the last three posts and statuses, as I know the status table contains only the status that I put on my Facebook page. The posts table contains a shared link, posts made by me or other users, so I want to: compare the last three statuses with the last three posts and take only the most 3 new (created date) from them, so I need to make check the created date or updated date for both sides and the output should be three.
I have tried:
Take the last three posts and the last three statuses, compare the updated date with the most updated three, put them in an array. That took a lot of PHP code. Can I do that with FQL?
You can get the last three posts and statuses via Graph API. Use:
https://graph.facebook.com/fb_id?fields=id,name,statuses.limit(3).fields(message),posts.fields(message,caption,description)
For more help, https://developers.facebook.com/tools/explorer
FQL
For getting statuses
SELECT status_id, message FROM status WHERE uid=fb_id
For getting posts
SELECT post_id, actor_id, target_id, message FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden = 0
But for all these you should have the permissions for accessing them. See
http://developers.facebook.com/docs/reference/fql/stream/.

Categories