Archive

Author Archive

Twitter PHP scripts

November 3rd, 2009 Spryt 1 comment

I’m a PHP programmer. No professional, but if I see the problem – I decide it. And Twitter – a new service for me, but some solution are not convenient for me. I learned the Twitter API to decide thise problems =)

API is very simple. Many operations can use simple HTTP request and XML report. Let’s get started:

About User
This operation shows all about user. Name, url, bio, followers, friends and twits count, creation date, last status and other. You can make user preview, followers counter, etc. Example:


<?php
function get_user($user,$is="user") {
if($is=="user"$content=file_get_contents("http://twitter.com/users/show.xml?screen_name=$user");
else if($is=="id"$content=file_get_contents("http://twitter.com/users/show.xml?user_id=$user"); 
preg_match_all("/<(.*)>(.*)<\/(.*)>/"$content$id); 
for($i=0$i<count($id[0]); $i++){ if($i==15) {$k="created";} else {$k=$id[1][$i];} $arr[$k]=$id[2][$i];} 
return $arr;}

//Example to counter:
$arr=get_user("User");
echo "Followers: $arr[followers_count]"//Example to preview:
$t=ceil((time()-strtotime($arr[created]))/86400);
if ($arr[followers_count]!=0) {$ratio=round($arr[friends_count]/$arr[followers_count],2);} else {$ratio="-";}
echo "<table border=0 width=900 style=\"border: 1px gray double;\">
<tr><td valign=top><img src=\"$arr[profile_image_url]\" width=48 height=48> 
<td valign=top><a href=\"http://twitter.com/$arr[screen_name]\">@$arr[screen_name]</a>: 
Ratio: $ratio - $arr[friends_count] | <b>$arr[followers_count]</b> | Twits: $arr[statuses_count] | $t days
<br>$arr[description] (<a href=\"$arr[url]\">$arr[url]</a>)<br>
<i>$arr[text]</i><br></table><br>";
?>

Followers and Friends
Get a follower and friends list of user (all who are not sealed off). Use to analysts.


<?php
function get_friends($user,$is="user") {
if($is=="user"$content=file_get_contents("http://twitter.com/friends/ids.xml?screen_name=$user");
else if($is=="id"$content=file_get_contents("http://twitter.com/friends/ids.xml?user_id=$user");
preg_match_all("/<id>(.*)<\/id>/"$content$ids); return $ids[1];}

function get_followers($user,$is="user") {
if($is=="user"$content=file_get_contents("http://twitter.com/followers/ids.xml?screen_name=$user");
else if($is=="id"$content=file_get_contents("http://twitter.com/followers/ids.xml?user_id=$user");
preg_match_all("/<id>(.*)<\/id>/"$content$ids); return $ids[1];}

//Example Friend of Follow
$name="User";
$fre=get_friends($name);
$fol=get_followers($name);
$friends=array_intersect($fre,$fol); echo count($friends)." Friends are following $name, and $name following them back<br>";
$following=array_diff($fre,$fol); echo count($following)." Following by $name, but they're not following $name back<br>";
$funs=array_diff($fol,$fre); echo count($funs)." Funs are following $name, but $name not following them back<br>";

foreach ($friends as $v) {$arr=get_user($v,"id"); echo "$arr[screen_name] |";} //Print names of friends
?>

Follow and UnFollow
It’s automatize follow. Need authorize, curl.


<?php
function friendship($username$password$twiname,$do){
if ($do=="follow") {$url "http://twitter.com/friendships/create/{$twiname}.xml";}
else if ($do=="unfollow") {$url ="http://twitter.com/friendships/destroy/{$twiname}.xml";}
$c curl_init();
curl_setopt($cCURLOPT_URL"$url");
curl_setopt($cCURLOPT_CONNECTTIMEOUT2);
curl_setopt($cCURLOPT_RETURNTRANSFER1);
curl_setopt($cCURLOPT_POST1);
curl_setopt($cCURLOPT_USERPWD"$username:$password");
$content curl_exec($c);
curl_close($c);
preg_match("/<following>(.*)<\/following>/"$content$ids);
return $ids[1];}

//Example:
friendship("User(you)","password","WhereFollow","follow");

//Follow all, who following you
$name="User"$pass="password";
$fre=get_friends($name); $fol=get_followers($name);
$funs=array_diff($fre,$fol);

foreach ($funs as $v) {echo "$v: ".friendship($name,$pass,$v,"follow").", "sleep(1);}
echo " followed (".count($funs).")";

//Unfollow All, who don't follow you:
$name="User"$pass="password";
$fre=get_friends($name); $fol=get_followers($name);
$following=array_diff($fre,$fol);

foreach ($following as $v) {echo "$v: ".friendship($name,$pass,$v,"unfollow").", "sleep(1);}
echo " unfollowed (".count($following).")";

//Follow all, who following Other user:
$user="FollowHisFriends";
$name="User"$pass="password";
$fre=get_friends_user($name)
$fre2=get_friends_user($user); 

$difre=array_diff($fre2,$fre); //Who follow User, but not following you

foreach ($difre as $v)  {echo "$v: ".friendship($name,$pass,$v,"follow").", "sleep(1);}
echo " followed (".count($difre).")";
?>

Limits
Request per hour – 150. Use many IP’s for more request.
Follow limit – 2000 OR 110% of your followers.

Usage
Use your own scripts to manage your Twitter Account – it’s free and full control. Use cron to automatic follow user, who following you. Create individual widgets, counter, previews and other – for great view on your blog. But.. don’t be evil – no spam, please.

Interesting? Subscribe on my RSS Feed and follow me on Twitter!

Categories: Scipts Tags:

October results

November 2nd, 2009 Spryt No comments

In my russian blog I write every month results, including earnings. This is a good idea – archive history, and it shows my readers what I do (2,5, I write them). If I tell people about making money, where is my results?) So, I continue this tradition.

In October my total profit is $800. Including:

Sale Links: 300$
Referial earnings: 220$
Media ads: 170$
AdSense: 28$ (two weeks work)
..and little money in other ways.

Of course, all of this – in russian-speaking internet. In English Internet I did not earn) And my first goal – increase profit in this direction. At this time I have one blog (this), and some ideas for sites and service (in twitter).

Blog stats are very small. I have ~10 RSS readers and 35 followers in Twitter, three posts and two comments. Unique visitors – 184, but only 16 – in USA. Alexa rank is 11M =) In November I’ll try promote my blog and twitter (for it’s very interesting for me).

And how much you earned online in October?)

Categories: Results Tags:

Choosing a site niche

October 28th, 2009 Spryt 1 comment

Choosing subjects of future site is very important. You can choose no one needed a niche, and your site will be doomed to failure. You can choose the contrary, the too niche, and you’ll be overwhelmed with tons of competitors. Even if you did everything correctly, the site is, the attendance good .. But it may fail in monetization, and you can not normally earning on site – as chosen niche is economically unprofitable. Therefore, we must carefully select the theme of the site. What you should pay attention:

Your interest
It will be much better if you yourself would be interested in this niche. In this case, you and you know what information must be on the site, whom it will be interesting, etc. If you still do not know what you want – make a note on the paper everything that you’re interested in (from stamp collecting and ending with iPhone), and gradually forget to remove not suitable niches. Thus you will come to some ideas that can be implemented.

The interest of users
Remove rare subjects. Etymology of ancient Egyptian – this is certainly interesting, but completely wasted. Try google information on selected topics, if the activity is (a normal page in wikipedia, websites, discussion, etc.) – means you can use.

Monetization
The goal is not to simply create a website. It is necessary to receive money from the site.. It’s time to check how it would be advantageous. Check the price of clicks in AdWords, as well as the presence of advertisers. If your site is about something that you can sell – well, then you can use affiliate sales. A lot of the price information? That means you can sell ebooks and manuals. Just think about how you can earn with your site.

Competition
It’s time to descend from heaven to earth to check competitors. Google for this irreplaceable – check the number of pages per issue in the main and secondary keywords, as well as sites in Top. Can you compete with them? If not, try a more narrow niche. Start with small, and gradually you can move your competitors and take their rightful place

PROFIT!
Chose a niche? It’s time to start creating a website =) This is in the following post.

————————

Lee Ka Hoong told about Make Money Online With Web Hosting Affiliate Program. This is interested idea, although it is not new.

Jeandsen than told about 10 myths in adsense – Part 1 and Part 2. This is the question of monetization – not all niches are equally good.

PS. If you find a spelling error – let me know (Thanks, Google Translate).

Categories: Sites Tags:

Welcome to my Blog

October 21st, 2009 Spryt 2 comments

Hello! My nickname is Spryt. I’m from Russia, and I’m 19 years old. I earn money on the internet (russian-speaking internet, runet). And now I’m interested in earnings in the english-speaking internet. Also, in runet I have a mid-popular blog (1300 readers) about making money online (SEO, experiments, blogging, etc.), and this blog – an adaptation for the english-speaking internet.

My goal – to increase my earnings. Now I earn about 1000 $ per month, mostly in runet – selling links and banners on my sites, referial earnings and other. That is quite enough to live in Russia, but it is not enough for beautiful life =) And as for life in another country. I started with the creating of websites (including this blog), for their subsequent monetization in Google AdSense. This is what I’m going to write in this blog – about earning money online without offline work.

And, my english is very bad, sorry. However, Google Translate and friends help me in this issue =) Another goal – learning english (I know a little language, but not enough to free communication). If you find a spelling error – please let me know (in comments).

Hmm.. That is it!

Categories: Blog Tags: