Yesterday I had some trouble with Facebook comment for Joomla 3.2.0. And for today i have to count the article's counts separately. So have the code from facebook but can't get the data-href right.
<span>Comments:<fb:comments-count data-href="<?=JURI::current()?>"></fb:comments-count></span>
So this data-href="<?=JURI::current()?>" is have to be changed i think. All articles have their own facebook comments so now i need is to have their own comment counting.
Question2: If there is no comment it's get just blank like Comments: ... so is there anyway to display non commented articles to have like Comments: 0.
Try this,
https://api.facebook.com/restserver.php?method=links.getStats&urls=[URL]
You can use restserver.php for getting count of share,like,comment etc
<?php
$url = 'https://www.facebook.com/Walkswithme';
$xml = simplexml_load_file("http://api.facebook.com/restserver.php?method=links.getStats&urls=".$url);
$counts = $xml->link_stat->comment_count;
?>
for more details
where you need the comment count just use like <?php echo $counts;?>
Hope its helps..
Related
Here's some code:
$facebookUrl = 'https://graph.facebook.com/'.$facebookPageId.'/posts?&access_token='.$facebookAppId.'|'.$facebookAppSecret;
$facebookData = json_decode(curlRequest($facebookUrl))->data;
curlRequest is successfully returning data but it's limited. The response has the following items:
message
story
created_time
id
It's bad enough these don't include a photo (which all of these posts do) but what's worse is that I have no link that takes me to the post.
Twitter has a redirect using 'https://twitter.com/statuses/'. $post->id; does Facebook have something similar? Or better yet how do I get all of the data for these posts?
Link to the post would be
$facebookUrl = 'https://graph.facebook.com/'.$facebookPageId.'/posts?&access_token='.$facebookAppId.'|'.$facebookAppSecret;
$facebookData = json_decode(curlRequest($facebookUrl))->data;
$link = "http:/fb.com/".$facebookData->id; //This short link will redirect to the pages' post
The $facebookData->id is made up of unique values i.e. the part before "_" (underscore) describes the parent (page,user,group,event) and string after underscore is the post id of its parent.
Adding to Nishant's helpful answer above, Facebook has a lot of other data you can get as part of the Post object, as outlined in their docs. By default, though, all it sends is
message
story
created_time
id
In order to retrieve any other fields, the request has to specify those fields in the query params. For example, if I want the picture and link associated with a Post, I would construct my GET request thus:
https://graph.facebook.com/POST_ID?fields=picture,link&access_token=YOUR_TOKEN
And I would get a response like this:
{
"link": "http://example.com/link",
"picture": "https://example.com/picture",
"id": POST_ID
}
I don't know PHP so can't give the specific syntax for OP's question, but this should get you most of the way there.
Example link for Facebook post:
facebook.com/123123123/posts/890890890/
pattern:
facebook.com/{{page_id}}/posts/{{post_id}}/
where from API post_id => {{page_id}}_{{post_id}}
I'm new on this community, and I'll be very grateful if someone can help me with this.
Well, I'm trying to get the information from any article, by ID or by [object].
The idea is, "do some actions" for all of these data, extracting the "title", "content", etc. then manipulate this information.
Some code that I think it could be usefull:
$model = JModelLegacy::getInstance('Articles', 'ContentModel');
$articles = $model->getItems();
"$articles" saves an array, right? which contains all my articles indexed from 0->N.
Now when I use it in a foreach for example, like:
foreach($articles as $newArt){
echo $newArt->get("alias");
}
"echo" returns nothing.
Actually I tested [echo $articles[0 or 1 ...]; ] same ... nothing.
Any ideas for what is the problem?
EDIT:
I was wrong calling attributes using get("alias").
$newArt->alias;
Simple :').
I am trying to add a custom link to a custom page using the vtiger_link table, with 2 parameters; 1 is the trouble ticket id which works fine:
This is in the URL field in the database:
modules/Helpdesk%20Info/index.php?ticketid=$RECORD$"target='helpdeskinfo'
and 2 is the id of the logged in user ($current_user) but it doesn't work:
modules/Helpdesk%20Info/index.php?ticketid=$RECORD$&$user=$current_user"target='helpdeskinfo'
It shows the page just as it should, but the variable $user gets the value '$current_user':
http://localhost:8888/modules/Helpdesk%20Info/index.php?ticketid=135409&$user=$current_user
I wanted to post a picture of the table, but I don't have enough reputation for that.
I have tried many things, but I am clearly doing something wrong.
Any help would be much appreciated.
I did not need to put the variable in the URL,
the reason I could not use the $current_user variable is because it didn't exist in "detailview.php" which is where the link ends up.
I used:
echo "<pre>";
print_r($GLOBALS);
echo "</pre>";
to view all globals, there I found the authenticated_user_id
Knowing I could use this I was able to access the global from my file without the URL:
$current_user = $_SESSION["authenticated_user_id"];
I would like to thank STT LCU for his advice, as he was the only one who helped me through this problem, which took me a full week in total.
I'm trying to create a widget like the Facebook widget found on this site. I'm not sure how they've done it but somehow they're pulling in the number of Facebook likes from their page via the API. I've found a few examples online but none seemed to work. Is it possible someone could point me in the direction of how I can display the number of Facebook likes (for a page) as text?
Please note that the site I need it for is Wordpress so either an existing plugin or just PHP code will work!
This is how you can do it in php:
$fb_handle = "GideonShalwickUpdates";
$graph_url = "https://graph.facebook.com/".$fb_handle."?fields=likes";
$get_data = file_get_contents($graph_url);
$get_json = json_decode($get_data);
$likes = $get_json->likes;
echo $likes;
I have a page that shows the latest 50 pics of a certain #hashtag.
I'd like the user to click on the image and go to a page, of the same website, where I can show the full size pic, the title ....
I've searched a lot but I cannot find a way to get the info of a single picture.
Something like this: http://snapwidget.com/view/?id=273145283494542941_10884350#.UE9ukhhwPw8
Thank you!
Have you checked out the Instagram API?
You can use:
https://api.instagram.com/v1/media/MEDIA-ID?access_token=ACCESS-TOKEN
to get the info I've passed the image id in a $_GET variable... Something like this:
http://yoursite.com/image.php?id=3
<?php
//image.php
$image = $_GET['id'];
$info = 'https://api.instagram.com/v1/media/'.$image.'?access_token='.$token;
$response = json_decode($info, true);
//example for full size image
$fullsize = $response['images']['standard_resolution']['url'];
echo '<img src="'.$fullsize.'"/>';
?>
EDIT: also have a look at THIS, it's a PHP wrapper for Instagram, very useful!
I use the shortcode:
From the imgage url, I get the shortcode: eg.: https://instagram.com/p/2rqCzTTdUX/ -> 2rqCzTTdUX
Then, with the following endpoint:
https://api.instagram.com/v1/media/shortcode/{shortcode}?access_token=ACCESS_TOKEN
I get the same data as with the media/{media_id} api. Then, I look for the param 'id' at top level
of data (in the json api's response) -> '985065853803556759_429959980'
Finally, for example, I can use the api get media:
v1/media/{media_id}?access_token=ACCESS_TOKEN