<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>nessio.net - blog &#187; PHP-Script</title>
	<atom:link href="http://blog.nessio.net/tag/php-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nessio.net</link>
	<description>Development, Webseiten, Apps und einfach nur ein Blog.</description>
	<lastBuildDate>Mon, 21 Jun 2010 08:37:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Automatisch Leuten bei Twitter folgen</title>
		<link>http://blog.nessio.net/2009/06/02/automatisch-leuten-bei-twitter-folgen/</link>
		<comments>http://blog.nessio.net/2009/06/02/automatisch-leuten-bei-twitter-folgen/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 14:08:22 +0000</pubDate>
		<dc:creator>Benni</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Follow]]></category>
		<category><![CDATA[followscript]]></category>
		<category><![CDATA[friendships]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP-Script]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[TwitterUser]]></category>
		<category><![CDATA[Xml]]></category>

		<guid isPermaLink="false">http://blog.nessio.net/?p=141</guid>
		<description><![CDATA[Viele TwitterUser versuchen möglichst viele User mit gleichen Interesse zu verfolgen. Dies alles manuell per Hand zu machen ist sehr Zeit aufwendig und anstrengend, weshalb ich mir ein PHP-Script gebaut habe, was dies automatisch tut. Als erstes müssen die User-Daten sowie die Such-Variable festgelegt werden. 1 2 3 $username = $_GET&#91;'user'&#93;; $password = $_GET&#91;'pw'&#93;; $search [...]]]></description>
			<content:encoded><![CDATA[<p>Viele TwitterUser versuchen möglichst viele User mit gleichen Interesse zu verfolgen. Dies alles manuell per Hand zu machen ist sehr Zeit aufwendig und anstrengend, weshalb ich mir ein PHP-Script gebaut habe, was dies automatisch tut.</p>
<p>Als erstes müssen die User-Daten sowie die Such-Variable festgelegt werden.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pw'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$search</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'search'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Sollen die Parameter später nicht über die URL gefüllt werden, so muss das jeweilige $_GET['*']; durch &#8216;*&#8217;; ersetzt werden.</p>
<p>Um an die User mit gleichen Datensätzen zukommen, müssen wir erst mal ein XML-Generieren welches die Gewünschten Daten beinhaltet.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://search.twitter.com/search.atom?q='</span><span style="color: #339933;">.</span><span style="color: #000088;">$search</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;amp;rpp=30'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Hier wird einfach nur nach dem Wort aus $search gesucht und das ganze in die Variable $result gespeichert, wobei die rpp=30 die Ergebnisse auf 30 begrenzt.</p>
<p>Um nun die 30 Einträge auszulesen verpacken wir das ganze in eine Schleife, geben die Twitter-API Adresse sowie den CURL Befehl an und fertig ist das automatische &#8220;Follow Script&#8221;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$count</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$follow</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;;</span>entry<span style="color: #009900;">&#91;</span><span style="color: #000088;">$count</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;;</span>author<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;;</span>uri<span style="color: #339933;">,</span> <span style="color: #cc66cc;">19</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// The twitter API address</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://twitter.com/friendships/create.xml'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Set up and execute the curl process</span>
<span style="color: #000088;">$curl_handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$url</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;screen_name=<span style="color: #006699; font-weight: bold;">$follow</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_USERPWD<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$username</span>:<span style="color: #006699; font-weight: bold;">$password</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// check for success or failure</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'message'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'success
'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$count</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Das Script wird mit folgendem befehl aufegrufen. (AChtung: meine Script Datei heißt followscript.php)</p>
<blockquote><p>http://www.host.de/followscript.php?user=<strong>Twitteruser</strong>&amp;pw=<strong>Userpw</strong>&amp;search=<strong>Suchbegriff</strong></p></blockquote>
<p>So das war&#8217;s! Solltet ihr Fehler finden oder andere Unstimmigkeiten meldet mir diese bitte, vielen dank!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nessio.net/2009/06/02/automatisch-leuten-bei-twitter-folgen/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
