export twitter followers list to csv file - php

I use the following php code to get a user twitter followers. I want to export this data to a csv file and add a filter to save only followers with more than 100 followers.
<script src="http://code.jquery.com/jquery-latest.js"></script>
<?php
$trends_url = "http://api.twitter.com/1/statuses/followers/pthiongo.json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $trends_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curlout = curl_exec($ch);
curl_close($ch);
$response = json_decode($curlout, true);
foreach($response as $friends){
$thumb = $friends['profile_image_url'];
$url = $friends['screen_name'];
$name = $friends['name'];
echo $friends['screen_name'];
?>
<a title="<?php echo $name;?>" href="http://www.twitter.com/<?php echo $url;?>"><img class="photo-img" src="<? php echo $thumb?>" border="0" alt="" width="40" /></a>
<?php
}
?>

First this , http://blog.gabrieleromanato.com/2012/06/jquery-get-twitter-followers-count/
Then use an if (followers_count > 99) in PHP to display

Programatically, you can request a list of up to 100 of your own followers with the Instagram API using the sample request below.
The sample request below is from SnippetLib:
https:api.instagram.comv1users3followed-by?access_token=ACCESS-TOKEN
This route (from nbyim.com) uses pagination to get around the rate limits:
from instagram.client import InstagramAPI
user_id=''
access_token = ''
client_secret = ''
api = InstagramAPI(access_token=access_token, client_secret=client_secret)
followers = []
# Get the followers list
for p in api.user_followed_by(user_id=user_id, as_generator=True, max_pages=None):
followers.extend(p[0])
# Convert from an instagram.models.User list to a list of strings
followers = [str(u).replace('User: ', '') for u in followers]
print len(followers), 'followers'
print followers
To automate the CSV process, you can use a service like Crowdbabble: https://www.crowdbabble.com/download-all-instagram-followers/

Related

It is possible get the media of another user? Instgram API

This code that I took form another web, works! but only when I put my Instragram ID. Otherwise when I want to get a media from another user (changing the variable userid) it stops working.
To be sure I use https://www.otzberg.net/iguserid/index.php to get the user ID.
And to get the Access Token (only with my account): http://instagram.pixelunion.net/
<?php
// Supply a user id and an access token
$userid = "-----";
$accessToken = "---";
// Gets our data
function fetchData($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
// Pulls and parses data.
$result = fetchData("https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}");
$result = json_decode($result);
?>
<?php if(!empty($result->data)): ?>
<?php foreach ($result->data as $post): ?>
<!-- Renders images. #Options (thumbnail,low_resoulution, high_resolution) -->
<a class="group" rel="group1" href="<?= $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a>
<?php endforeach ?>
<?php endif ?>
The link you posted clearly indicates that the token only works with your own images.
In order to display your Instagram photos on your own website,
you are required to provide an Instagram Access Token.
You should try a different API or method to show images from another user.

Getting an image from a facebook post on a public page

I'm trying to show a facebook feed on my website, which is working. But I only managed to show the text of the post, not the image attached to it (or if possible, if there are multiple images, only the first one or biggest one).
I tried looking here for the correct name to get it using the API
This is my code now (which shows facebook posts in an owl carousel):
function fetchUrl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
// You may need to add the line below
// curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
$feedData = curl_exec($ch);
curl_close($ch);
return $feedData;
}
//App Info, needed for Auth
$app_id = "1230330267012270";
$app_secret = "secret";
//Retrieve auth token
$authToken = fetchUrl("https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=1230330267012270&client_secret=secret");
$json_object = fetchUrl("https://graph.facebook.com/267007566742236/feed?{$authToken}");
$feedarray = json_decode($json_object);
foreach ( $feedarray->data as $feed_data )
{
if($feed_data->message != ''){
$facebookfeed .= '
<div class="item">
<div class="product-item">
<img class="img-responsive" src="images/siteimages/imgfacebook.jpg" alt="">
<h4 class="product-title">'.$feed_data->name.'</h4>
<p class="product-desc">'.$feed_data->message.'</p>
<p>'.$feed_data->story.'</p>
<img src="'.$feed_data->picture.'">
<p>Lees meer</p>
</div><!-- Product item end -->
</div><!-- Item 1 end -->';
}
}
echo $facebookfeed;
Looking at the Facebook documentation I thought $feed_data->picture would work, but it returns nothing.
To try to improve performance on mobile networks, Nodes and Edges in v2.4 requires that you explicitly request the field(s) you need for your GET requests. For example, GET /v2.4/me/feed no longer includes likes and comments by default, but GET /v2.4/me/feed?fields=comments,likes will return the data.
Source: https://developers.facebook.com/docs/apps/changelog#v2_4

Php curl missing content from page

$url = "http://www.ksl.com/index.php?nid=231&sid=74268&cat=&search=&zip=&distance=&min_price=&max_price=&type=&category=&subcat=&sold=&city=&addisplay=%5BNOW-1HOURS+TO+NOW%5D&sort=1&userid=&markettype=sale&adsstate=&nocache=1&o_facetSelected=true&o_facetKey=ad+posted&o_facetVal=Last+Minute&viewSelect=list&viewNumResults=48&sort=1";
$html = file_get_contents($url);
This returns some of the page content. I think that because the page I am trying to curl uses jquery to insert the listings the curl executes before the jquery populates the page?
Any ideas on how to get the full contents of the search curl?
Try this:
$url = 'http://www.ksl.com/index.php?nid=231&sid=74268&cat=&search=&zip=&distance=&min_price=&max_price=&type=&category=&subcat=&sold=&city=&addisplay=%5BNOW-1HOURS+TO+NOW%5D&sort=1&userid=&markettype=sale&adsstate=&nocache=1&o_facetSelected=true&o_facetKey=ad+posted&o_facetVal=Last+Minute&viewSelect=list&viewNumResults=48&sort=1';
/* gets the data from a URL */
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$returned_content = get_data($url);
echo $returned_content;
No they are not getting the listings via jQuery, AJAX. There are no XHR requests.
A view source shows the listings.
I just used this code to get
header('Content-Type: text/plain; charset=utf-8');
$url = 'http://www.ksl.com/index.php?nid=231&sid=74268&cat=&search=&zip=&distance=&min_price=&max_price=&type=&category=&subcat=&sold=&city=&addisplay=%5BNOW-1HOURS+TO+NOW%5D&sort=1&userid=&markettype=sale&adsstate=&nocache=1&o_facetSelected=true&o_facetKey=ad+posted&o_facetVal=Last+Minute&viewSelect=list&viewNumResults=48&sort=1';
$data = file_get_contents($url);
echo $data;
The Result
Partial edited
Black Xbox 360 320gb Hard Drive Plus controllers and G...</a>
<span style="color: #555;">Magna, UT
| 1 Min
<div class="adDesc">
Selling because I got it used then only used it once, works fantastically and comes with lots of games plus 4 controllers and a keyboard for the contr
<a class="listlink" href="?nid=218&ad=34170943&cat=&lpid=&search=&ad_cid=7">more...</a>
<div class="priceBox">
<a href="?nid=218&ad=34170943&cat=&lpid=&search=&ad_cid=7">
<span >$450<span class="priceCents">00
<!-- <div class="adDays">1 Min -->
<!--<div class="adTime">Dec 31, 1969-->
<div class="detailBox">
Great PS4 Bundle</a>
<span style="color: #555;">Spanish Fork, UT
| 1 Min
Have here a great PS4 bundle with 6Games 1controller and 3months of PS Network. Still has the box. Text 801-633-1659
<span >$400<span class="priceCents">00

Limit Instagram Feed in Php-Fetch

i am using the code below, to show some photos of my instagram-account on my website. it just fetches all the images of my account in the div. Is there a way to limit the fetched data to 10 Images or so ?
Cant figure out how to do that..
thanks for your help!
<div id="instagramfeed">
<?php
// Supply a user id and an access token
$userid = "123xy";
$accessToken = "123xy ";
// Gets our data
function fetchData($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
// Pulls and parses data.
$result = fetchData("https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}");
$result = json_decode($result);
?>
<?php foreach ($result->data as $post): ?>
<!-- Renders images. #Options (thumbnail,low_resoulution, high_resolution) -->
<a class="group" rel="group1" href="<?= $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a>
<?php endforeach ?> <br><br><br><br>
</div>
You could use the count parameter.
https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}&count=10
It was a problem in Instagram Developer Console. max_id and min_id doesn't work there.
For anyone interested - i found a solution for this problem:
it doesnt work with: {$accessToken}&count=10
But it works with:
?access_token=123456789101112131415123123111&count=10

Get all followers Email Ids in twitter in website

How can I get my Followers EmailID in Twitter? I have try the following code, but it does not return emailids, it returns only Name and Screen.
<script src="http://code.jquery.com/jquery-latest.js"></script>
<?php
$trends_url = "http://api.twitter.com/1/statuses/followers/gunarsekar.json";
////// exmaple $trends_url = "http://api.twitter.com/1/statuses/followers/w3cgallery.json"; or $trends_url = "http://api.twitter.com/1/statuses/followers/22250021.json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $trends_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curlout = curl_exec($ch);
curl_close($ch);
$response = json_decode($curlout, true);
// print_r($response);
foreach($response as $friends){
print_r($friends);
echo "<br><br>";
$thumb = $friends['profile_image_url'];
$url = $friends['screen_name'];
$name = $friends['name'];
?>
<a title="<?php echo $name;?>" href="http://www.twitter.com/<?php echo $url;?>"><img class="photo-img" src="<?php echo $thumb?>" border="0" alt="" width="40" /></a>
<?php
}
?>
Please help me to get the Email Address from Twitter.
The Twitter API does not even provide the authenticated User's Email.........So,providing Follower's Email is out of question.......For sending Message,you should try API to send Direct Message
I use Abraham API
https://github.com/abraham/twitteroauth
How to send a Direct message using Abraham's oauth library
The Twitter API does not return a user's email address
Look over this https://dev.twitter.com/docs/faq#6718.

Categories