I'm trying to get the comment count on a WordPress post as a PHP variable.
For some reason comments aren't syncing properly between disqus and WordPress so get the comment count from WordPress locally isn't an option.
Does anyone have any ideas about how to go about this? There's an API and PHP wrapper but I'd like to see if there's an easier way before I get stuck into the API.
Thanks!
PS I need as a PHP variable so posts can receive an rating based on likes, favourites and comments so getting it in JS isn't really an option.
Thanks!
I don't think you have other options to get the data on the server side other than using the Disqus APIs.
I think that the correct API for doing this is: http://disqus.com/api/docs/threads/set/
You can understand how it works from this example in JS: http://help.disqus.com/customer/portal/articles/1131783-tutorial-get-comment-counts-with-the-api the results are the same, so it should be your code.
Related
we are facing a major issue on the Instagram API calling section using PHP (Codeigniter 3). First of all we want to tell you that our app in in live mode and we are very sure of that . The pagination URL object is coming blank after 20 images and we have tried different ways using the COUNT parameter on the section and the next_max_id and next_min_id but all in vain. So please suggest us some new way to do this section. We can not use javascript on this section according to our requirements.
Some of the small example are below how e call the api and what are we using.
https://api.instagram.com/v1/users/self/media/recent/?access_token=3963420514.440235f.df3a5b4f9d6546cb9512ffd0a13ae62f&count=13
https://api.instagram.com/v1/users/3963420514/media/recent?
Thank you in advance.
I checked your API response it has pagination data
just use the pagination.next_url to get the next set of 13 posts via API, I tried it, it worked with your API above.
If not you can also maually add &max_id={value of pagination.next_max_id} to the API to get next set of posts
After much struggle with getting Facebook to yield it's RSS feed for a page, it seems as though my futility levels have reached their peak.
JSON seems to work absolutely dandy for me and so to this end I am curious as to whether there are any plugins that would import FB JSON as blog posts since it seems that RSS XML's either going away or seriously b0rked. Can anyone recommend any plugins to accomplish this?
Another way to import facebook post in your blog is to use http://www.social2blog.com/ but work only with facebook page. Otherwise you can create your own php script:
get the post in json format from Facebook ( https://developers.facebook.com/docs/graph-api/reference/v2.0/post ) but first you need to know how get access token.
for each facebook post insert a relative wordpress post using wp_insert_post
Unfortunately after having suspicions confirmed, Facebook has killed this feature. A solution has been recommended here: https://stackoverflow.com/a/9778635/320681
Do you mean something like this: FeedWordPress.
It syndicates content from feeds that you choose into your WordPress weblog. Hope it helps
I have a non-programming answer to this old question. I'm adding it here in case it helps. OK, I started looking for complicated programming solutions involving SDKs and APIs or even plain old WordPress plugins. But it's frustrating, especially as there's a lot of out of date information out there.
It's really simple. Just use IFTTT. I had to create two recipes, one for normal FB posts and one for FB photo posts. But both worked right away, the FB posts appeared as plain WP posts in my WordPress dashboard, absolutely no problem and surprisingly simple.
Create an app then get proper permission from page admin to read the facebook page feed.Refer this documentation.
https://developers.facebook.com/docs/reference/api/
Problem with this method is you have to run a cron job and pull the data from Facebook.
DISQUS commenting system is nice. API is confusing me a bit, so if anyone can please guide me to the right directions.
What I want to do is to get the total number of comments from dynamic pages/posts and insert that number to a MySQL table so I can filter the posts of those pages according to the total comments number and display each post's comment number in the forontapage, sidebars etc. Of course, I would like to update those rows later with a function I'll create when new comments pop up. But what I am asking is just the way I can get them.
Below my disqus_indentifier:
var disqus_identifier = <?php echo $post_id ?>;
Thanks!
As you discovered, the Disqus comment count script is definitely the best solution for what you're trying to do. It doesn't require any API integration or database work. Simply paste the code on your site and it will automatically find the counts for all comment count links on the page and show the relevant Disqus comment count for each.
For anyone looking to do more granular work along these lines via our API, the best endpoint would probably be threads/details which returns the details for a thread (including the number of comments). As far as inserting that information into your database I'd recommend looking over basic SQL INSERT documentation.
We've also put together some sample API recipes which can help you jumpstart your API integration, including a threads/details PHP script.
Trying to implement Piwik using REST API over http but need a little help.
What I'm trying to do is get the analytics for a particular page where a custom field = x.
I'm not sure if I'm going about it the right way but I have this so far:
http://www.mysite.co.uk/dashboard/analytics/index.php?module=API&method=VisitsSummary.get&idSite=1&period=month&date=today&segment=customVariableValue1==x&filter_limit=20&format=xml&token_auth=xxxxxxxxxxxxxxxxx
My custom field is set up and viewable in the admin.
However the result just seems to return 0 for everything. I'm testing by inserting the url directly into a browser and also by fetching in php.
Also is there a method to get all statistics for a particular page and given date range where custom field = x? I can't seem to see one in the API docs.
Any help/ examples would be appreciated.
In case anyone else happens to be looking for this I ended up using the getPageUrl method:
$url = "http://www.mysite.co.uk/piwik/index.php?module=API&method=Actions.getPageUrl&pageUrl=/foo.php?id=" . $id . "&idSite=1&period=month&date=today&format=php&filter_limit=1&token_auth=xxxx";
regards,
fl3x7
I tried with graph api asked many things to there but none of them are returns comments.
I want to get all comments, and put in a separate page for search engines to scan and index.
comments are very rich full and I want them
You can retreive comments (actually posts and their comments) from the Comments plugin from this api url:
https://graph.facebook.com/comments/?ids={$url_of_your_page}
please see the documentation here: http://developers.facebook.com/docs/reference/fql/
the table you need to query is this here:
http://developers.facebook.com/docs/reference/fql/comment/
(it is also one of the first examples)
the key is that you can specify an identifier for every comment plugin that you embed. using this identifier you can then select comments using the graph api.
regarding search engines you should not make the impression that you are serving different content to the spiders than to the users so it would probably be a good idea to load the comments over the api by default (please cache them) and then replace it by the javascript box if javascript is available, so the users can write new comments.
even better (in my opinion) would be always to display the comments in html in your website and only load the facebook comments plugin if the user wants to make a new comment. but that probably requires one additional step for the user.
you can also read about the ajax chrawling scheme
If you want to use the graph API what you do is grab the comment ID in the json (the very first number you see and it appears as {user_id}_{status_message_ID} example: 1234_5678910) and then have https://graph.facebook.com/{the number you got}?access_token={access token}
Do reduce strain what you could do is run the system that you do to put all the status messages and comments onto your website (for instance a 'for each' or 'while' statements etc) then add an 'if' statement that says if count (under comments on the json) is more than 3 it'll retrieve the json for that post using the id and spit out your data.
I hope this was of some help. Please say if you want anything explained further.
Regards,
Jon
You can use this url to get comments of an url and paginate them:
?fields=og_object{comments.order(reverse_chronological).limit(10).after(NgZDZD)}&id={YOUR_URL}
Even It works with latest(v2.10) graph version.