What is the simplest way to display Instagram follower count - api

I am using WordPress and trying to figure out the simplest way to display the amount of Instagram followers a user has.
Whilst searching I have found a few Instagram PHP wrapper scripts that seem a little overkill for what I am trying to display.
From reading through the Stackoverflow posts I came across a post that listed this code:
$userinfo = wp_remote_get("https://api.instagram.com/v1/users/3955450?access_token=f0d225aa955c4bd9ae563f87f831efab");
$userinfo = json_decode($userinfo);
$followers = $userinfo['data']['counts']['followed_by'];
echo "Folled by: " . $followers . " people";
This is a simple and perfect script HOWEVER it does not return any data.
I have setup a client on the Instagram Developer site however I cannot get the above script to display any data.
Any help would be greatly appreciated.

Try this:
$result = file_get_contents("https://api.instagram.com/v1/users/3955450?access_token=f0d225aa955c4bd9ae563f87f831efab");
$obj = json_decode($result);
echo $obj->data[0]->id;

Related

Anchor podcast public api

Can I get the list of episodes of my anchor account in JS. Anchor give us embed code which is iframe.
Can I get the episode name with any public API?
My requirement is to show the list of all episodes of specific person on anchor platform on my mobile app.
Podcasts are based on RSS feeds, so yes, you can get all the details of your podcast by loading and reading the RSS feed off any podcast.
The RSS URL of the Anchor podcasts is https://anchor.fm/s/PODCAST_ID/podcast/rss where PODCAST_ID is the ID of your podcast.
Q: Can I get the episode name with any public API?
There is no Public API from Anchor I think... And I need also to create my own landing page for my Podcast on Anchor. Then I look up the source code in my anchor page and I saw the window.__STATE__ variable in the source code.
Hmmm... It is very nice to me! With the window.__STATE__ I can catch json value after using my dirty PHP Code. Just implements some built-in method PHP have:
file_get_contents()
substr()
strpos()
str_replace()
and additional method if you want to save json code in your internal file using:
file_put_contents()
This is my dirty PHP code (but it's work nicely!)
<?php
$html = file_get_contents('https://anchor.fm/<your-podcast-page-name>');
$json = substr($html, strpos($html, 'window.__STATE__ = {') , strpos($html, '"isError":false}};') - (strpos($html, 'window.__STATE__ = {')-1));
$json = str_replace('window.__STATE__ = ', '', $json);
$json = str_replace('"isNewUser":false,"', '"isNewUser":false,"isError":false}}', $json);
file_put_contents('podcasts.json', $json);
Sorry for my bad English... Cheers!

Youtube API get feed ignore duplicates

I cannot find a way of getting youtube to not return duplicate videos in a feed.
I am currently using API v1 and I understand that v2 and v3 are where I should be moving too. I am using ZF 1 and its Gdata library not that it should matter if there is API level support for what I want to do.
However I cannot see the solution in either of those versions either.
Heres whats happening.
For some reason the server code is occasionally uploading duplicate videos in parallel.
Youtube detects that and then it seems to list a video on the feed as duplicate and it wont play.
https://gdata.youtube.com/feeds/api/users/username/uploads/?max-results=50
So I get 50 videos from that users account. Is there anyway to tell youtube, dont return videos that are duplicates.
I mean it almost seems obvious that it shouldnt right?
Does anyone know anything about filtering duplicates out of feeds?
I look at the data returned and theres no indication of a status or any other info which would provide me with a way to tell a clip is duplicate.
Hopefully someone knows the solution.
Cheers!
Both in V2 and V3 you got the status "rejected". Have you checked if this might be also in V1?
Okay, so I worked it out, turns out theres a state property which you can interrogate in the feed. See the code below to know how to check the state and ignore it if its been rejected.
Damn Zend Framework v1 Documentation is pretty much non-existent for this kind of thing.
$applicationId = 'App ID';
$clientId = 'Client ID';
$youtubeDeveloperKey = 'Developer Key';
$token = unserialize($gdata_oauth_access_token);
$httpClient = $token->getHttpClient($this->_oauthOptions);
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $youtubeDeveloperKey);
$url = 'https://gdata.youtube.com/feeds/api/users/' . $youtube_user_name . '/uploads/?max-results=50';
$videoFeed = $yt->getVideoFeed($url);
// process the feed
foreach ($videoFeed as $videoEntry) {
$state = $videoEntry->getVideoState();
if (is_object($state) && $state->name == 'rejected') {
// skip this video
continue;
}
}

Disqus API: get total forum number of comments/posts

I'm trying to get the total number of comments that have been written in a given forum.
Looking at http://disqus.com/api/docs/ I can't see anything like this. Honestly, it sounds weird.
Forum details ( http://disqus.com/api/docs/forums/details/ ) shows anything but.
Any hack/piece of code/hidden API call that would to the trick?
Thanks in advance
The best way I have found is to get the list of all the threads and then sum the number of posts for each one:
curl -0 -L "https://disqus.com/api/3.0/forums/listThreads.json?api_key=YOUR_API_KEY&forum=YOUR_FORUM_NAME&limit=100"
Dont forget to iterate over different pages of results if you get a 'next' cursor (response['cursor']['next']).
See this gist for a full JavaScript example (intended to run on Google Script):
https://gist.github.com/sarfata/5068200

Google+ API: Get Things I've +1ed

I want to fetch all of a user's Google Plus activity. I can get all of a user's posts but I can't find any way to fetch everything a user have +1ed or commented on. Can I?
There is an open feature request for access to a users +1'd URLs. I did not find a feature request for listing comments from a user but you can request it: http://bugpl.us/new.
use this php code and u get particular activity comment's list
$optParams = array('maxResults' => 100);
$comments = $plus->comments->listComments(activityid,$optParams);
foreach($comments['items'] as $comment) {
print "{$comment['id']}, {$comment['object']['content']}\n";
}

TwitPic filter by hashtag

I want to display twitPic photos with the hashtag of #animals. Currently, I am displaying photos through the username. This is my code below:
$username = "smcsconverse";
//this is your twitpic RSS feed...
$yourRSS = "http://twitpic.com/photos/".$username."/feed.rss";
However, I am now stuck with how retrieving pictures through a given hashtag. I have been stuck quite awhile on this.
Looks like twit pic has added a beta hashtag search. Here is the documentation.