<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Automatically subscribe users to DreamHost announce lists</title>
	<atom:link href="http://edwardawebb.com/web-development/automatically-subscribe-users-dreamhost-announce-lists/feed/" rel="self" type="application/rss+xml" />
	<link>http://edwardawebb.com/web-development/automatically-subscribe-users-dreamhost-announce-lists</link>
	<description>get all his digital goodness 24/7</description>
	<lastBuildDate>Sat, 04 Feb 2012 17:05:41 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Eddie</title>
		<link>http://edwardawebb.com/web-development/automatically-subscribe-users-dreamhost-announce-lists/comment-page-1/#comment-1546</link>
		<dc:creator>Eddie</dc:creator>
		<pubDate>Tue, 25 May 2010 17:57:12 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=560#comment-1546</guid>
		<description>@Dave

Thanks for the share Dave!  I am really glad this article helped you too.  DreamHost is building a great API that is useful for all sorts of domain admin scenarios.</description>
		<content:encoded><![CDATA[<p>@Dave</p>
<p>Thanks for the share Dave!  I am really glad this article helped you too.  DreamHost is building a great API that is useful for all sorts of domain admin scenarios.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Gamble</title>
		<link>http://edwardawebb.com/web-development/automatically-subscribe-users-dreamhost-announce-lists/comment-page-1/#comment-1308</link>
		<dc:creator>Dave Gamble</dc:creator>
		<pubDate>Sat, 06 Mar 2010 11:25:10 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=560#comment-1308</guid>
		<description>Heya, thanks for this article.

Here&#039;s the cleanup for the response testing:

$result will be ===FALSE if the curl operation itself fails.
(yes, triple equals.)

if (stripos($a,$b)&gt;1) is an improper test, please see:
http://php.net/manual/en/function.stripos.php

To correct the code above, you need to change:
if ( stripos( $result,&#039;success&#039;) &gt; 0){
to
if ( $result!==false &amp;&amp; stripos( $result,&#039;success&#039;)!==false){

This is because stripos returns logical false if it doesn&#039;t find it.
Another neat (perhaps better?) way to test would be !strncasecmp($result,&#039;success&#039;,7)

Also in your errorcode handling, you probably want to test the case where $result===false and report that as a failure to connect to the server.

Thanks very much, this tutorial helped me A LOT!! :D

Dave.</description>
		<content:encoded><![CDATA[<p>Heya, thanks for this article.</p>
<p>Here&#8217;s the cleanup for the response testing:</p>
<p>$result will be ===FALSE if the curl operation itself fails.<br />
(yes, triple equals.)</p>
<p>if (stripos($a,$b)&gt;1) is an improper test, please see:<br />
<a href="http://php.net/manual/en/function.stripos.php" rel="nofollow">http://php.net/manual/en/function.stripos.php</a></p>
<p>To correct the code above, you need to change:<br />
if ( stripos( $result,&#8217;success&#8217;) &gt; 0){<br />
to<br />
if ( $result!==false &amp;&amp; stripos( $result,&#8217;success&#8217;)!==false){</p>
<p>This is because stripos returns logical false if it doesn&#8217;t find it.<br />
Another neat (perhaps better?) way to test would be !strncasecmp($result,&#8217;success&#8217;,7)</p>
<p>Also in your errorcode handling, you probably want to test the case where $result===false and report that as a failure to connect to the server.</p>
<p>Thanks very much, this tutorial helped me A LOT!! <img src='http://edwardawebb.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Dave.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eddie</title>
		<link>http://edwardawebb.com/web-development/automatically-subscribe-users-dreamhost-announce-lists/comment-page-1/#comment-1294</link>
		<dc:creator>Eddie</dc:creator>
		<pubDate>Sat, 06 Feb 2010 17:34:51 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=560#comment-1294</guid>
		<description>Thanks Colin.  That is a very useful find.</description>
		<content:encoded><![CDATA[<p>Thanks Colin.  That is a very useful find.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin Goodier</title>
		<link>http://edwardawebb.com/web-development/automatically-subscribe-users-dreamhost-announce-lists/comment-page-1/#comment-1293</link>
		<dc:creator>Colin Goodier</dc:creator>
		<pubDate>Sat, 06 Feb 2010 03:49:56 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=560#comment-1293</guid>
		<description>Hi Eddie,

I got it. The answer is in the PHP manual entry for curl_exec()

&quot;Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER  option is set, it will return the result on success, FALSE on failure. &quot;

The way you&#039;ve got it set up you are returning TRUE or FALSE in $result, but you are checking for the result (i.e. &#039;success&#039;).

So if you add the line

curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

The &#039;stripos&#039; line should work correctly.

Colin</description>
		<content:encoded><![CDATA[<p>Hi Eddie,</p>
<p>I got it. The answer is in the PHP manual entry for curl_exec()</p>
<p>&#8220;Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER  option is set, it will return the result on success, FALSE on failure. &#8221;</p>
<p>The way you&#8217;ve got it set up you are returning TRUE or FALSE in $result, but you are checking for the result (i.e. &#8216;success&#8217;).</p>
<p>So if you add the line</p>
<p>curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);</p>
<p>The &#8216;stripos&#8217; line should work correctly.</p>
<p>Colin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin Goodier</title>
		<link>http://edwardawebb.com/web-development/automatically-subscribe-users-dreamhost-announce-lists/comment-page-1/#comment-1292</link>
		<dc:creator>Colin Goodier</dc:creator>
		<pubDate>Fri, 05 Feb 2010 02:46:34 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=560#comment-1292</guid>
		<description>Eddie,

Just re-read your response and took it in a bit more. You say

&quot;So the code you reference checks if the result contains success. (stripos returns 0 if false, otherwise the position), so we check that it is greater than zero, is that the “1″ your referring to?&quot;

That&#039;s what I thought it was doing. You&#039;re checking for the string &#039;success&#039; in $result, right? But I checked the value of $result, and it doesn&#039;t contain a string.
In the case of a successful operation it contains the value &#039;1&#039; (at least when I run it), which is presumably why the &#039;stripos&#039; line return an error. Maybe the Dreamhost guys changed something? It seems to be that $result contains a boolean value, not a string.

Colin</description>
		<content:encoded><![CDATA[<p>Eddie,</p>
<p>Just re-read your response and took it in a bit more. You say</p>
<p>&#8220;So the code you reference checks if the result contains success. (stripos returns 0 if false, otherwise the position), so we check that it is greater than zero, is that the “1″ your referring to?&#8221;</p>
<p>That&#8217;s what I thought it was doing. You&#8217;re checking for the string &#8216;success&#8217; in $result, right? But I checked the value of $result, and it doesn&#8217;t contain a string.<br />
In the case of a successful operation it contains the value &#8217;1&#8242; (at least when I run it), which is presumably why the &#8216;stripos&#8217; line return an error. Maybe the Dreamhost guys changed something? It seems to be that $result contains a boolean value, not a string.</p>
<p>Colin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin Goodier</title>
		<link>http://edwardawebb.com/web-development/automatically-subscribe-users-dreamhost-announce-lists/comment-page-1/#comment-1291</link>
		<dc:creator>Colin Goodier</dc:creator>
		<pubDate>Fri, 05 Feb 2010 02:28:25 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=560#comment-1291</guid>
		<description>Hi Eddie,

I just changed the code to check for &#039;1&#039; in $result, and it worked, in the sense that it no longer gave me the error message.

The thing is, the functionality worked fine, it did what it was supposed to (add a subscriber to the list), but it was giving me the output of the

echo &quot; Ooops! Unable to add your email to our announcement list please contact site administrator.&quot;;
			echo &quot;Code: &quot; . $result;

line, as if it hadn&#039;t worked (when it had).

I thought that &#039;stripos&#039; was checking for a particular text string in $result, which wasn&#039;t there, but maybe I misread that? 

Anyway, as I say, it seems to be working ok for me having made that one change, I just thought I&#039;d give you the feedback on it. It does the job fine!

Colin</description>
		<content:encoded><![CDATA[<p>Hi Eddie,</p>
<p>I just changed the code to check for &#8217;1&#8242; in $result, and it worked, in the sense that it no longer gave me the error message.</p>
<p>The thing is, the functionality worked fine, it did what it was supposed to (add a subscriber to the list), but it was giving me the output of the</p>
<p>echo &#8221; Ooops! Unable to add your email to our announcement list please contact site administrator.&#8221;;<br />
			echo &#8220;Code: &#8221; . $result;</p>
<p>line, as if it hadn&#8217;t worked (when it had).</p>
<p>I thought that &#8216;stripos&#8217; was checking for a particular text string in $result, which wasn&#8217;t there, but maybe I misread that? </p>
<p>Anyway, as I say, it seems to be working ok for me having made that one change, I just thought I&#8217;d give you the feedback on it. It does the job fine!</p>
<p>Colin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eddie</title>
		<link>http://edwardawebb.com/web-development/automatically-subscribe-users-dreamhost-announce-lists/comment-page-1/#comment-1290</link>
		<dc:creator>Eddie</dc:creator>
		<pubDate>Thu, 04 Feb 2010 22:25:05 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=560#comment-1290</guid>
		<description>@Colin
Sorry you&#039;re having troubles, let&#039;s see if we can&#039;t fix them.

When I wrote the article above it worked, and was based on the API documentation, http://wiki.dreamhost.com/Api#announcement_list-add_subscriber, which states;


&lt;blockquote&gt;
&lt;strong&gt;Result:&lt;/strong&gt;

success
sent_opt_in_email

&lt;strong&gt;Possible Errors:&lt;/strong&gt;

no_listname
no_domain
no_such_listname
no_such_domain
no_email
invalid_email (may have specifics after a tab)
already_subscribed
email_may_not_be_added_to_any_dreamhost_list_ever
email_requested_to_be_added_in_last_two_days_already 
internal_error_opting_in
&lt;/blockquote&gt;

So the code you reference checks if the result contains success. (stripos returns 0 if false, otherwise the position), so we check that it is greater than zero, is that the &quot;1&quot; your referring to?

You could use a series of if/else blocks to handle any scenario.

Do you have php debugging on? are you seeing any specific errors?</description>
		<content:encoded><![CDATA[<p>@Colin<br />
Sorry you&#8217;re having troubles, let&#8217;s see if we can&#8217;t fix them.</p>
<p>When I wrote the article above it worked, and was based on the API documentation, <a href="http://wiki.dreamhost.com/Api#announcement_list-add_subscriber" rel="nofollow">http://wiki.dreamhost.com/Api#announcement_list-add_subscriber</a>, which states;</p>
<blockquote><p>
<strong>Result:</strong></p>
<p>success<br />
sent_opt_in_email</p>
<p><strong>Possible Errors:</strong></p>
<p>no_listname<br />
no_domain<br />
no_such_listname<br />
no_such_domain<br />
no_email<br />
invalid_email (may have specifics after a tab)<br />
already_subscribed<br />
email_may_not_be_added_to_any_dreamhost_list_ever<br />
email_requested_to_be_added_in_last_two_days_already<br />
internal_error_opting_in
</p></blockquote>
<p>So the code you reference checks if the result contains success. (stripos returns 0 if false, otherwise the position), so we check that it is greater than zero, is that the &#8220;1&#8243; your referring to?</p>
<p>You could use a series of if/else blocks to handle any scenario.</p>
<p>Do you have php debugging on? are you seeing any specific errors?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin Goodier</title>
		<link>http://edwardawebb.com/web-development/automatically-subscribe-users-dreamhost-announce-lists/comment-page-1/#comment-1288</link>
		<dc:creator>Colin Goodier</dc:creator>
		<pubDate>Thu, 04 Feb 2010 17:42:41 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=560#comment-1288</guid>
		<description>Hi Edward,

Thanks for the code, very useful However, I&#039;m not sure if the line 

if ( stripos( $result,&#039;success&#039;) &gt; 0){

is right? I seem to be getting a &#039;1&#039; as the response in $result. Maybe boolean &#039;true&#039;? Leaving the code as above results in an error, although the subscription succeeds, and I get the &#039;success subscribed&#039; text ok, but it just appears in the form response page. I think the error was because $result doesn&#039;t contain the &#039;success subscribed&#039; response that your code seems to expect?

Maybe that needs to be handled differently.

Colin</description>
		<content:encoded><![CDATA[<p>Hi Edward,</p>
<p>Thanks for the code, very useful However, I&#8217;m not sure if the line </p>
<p>if ( stripos( $result,&#8217;success&#8217;) &gt; 0){</p>
<p>is right? I seem to be getting a &#8217;1&#8242; as the response in $result. Maybe boolean &#8216;true&#8217;? Leaving the code as above results in an error, although the subscription succeeds, and I get the &#8216;success subscribed&#8217; text ok, but it just appears in the form response page. I think the error was because $result doesn&#8217;t contain the &#8216;success subscribed&#8217; response that your code seems to expect?</p>
<p>Maybe that needs to be handled differently.</p>
<p>Colin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2010-02-03 &#124; Pratyush Kotturu - KE5YQZ</title>
		<link>http://edwardawebb.com/web-development/automatically-subscribe-users-dreamhost-announce-lists/comment-page-1/#comment-1287</link>
		<dc:creator>links for 2010-02-03 &#124; Pratyush Kotturu - KE5YQZ</dc:creator>
		<pubDate>Wed, 03 Feb 2010 18:04:28 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=560#comment-1287</guid>
		<description>[...]        DeliciousEngadget 4 hours agoFacebook Developers &#124; HipHop for PHP: Move Fast 15 hours agoAutomatically subscribe users to DreamHost announce lists &#124; Edward A. Webb (.com) 15 hours agoAbout PASCAL &#124; PASCAL 2 2010/02/02Cognitive Science and Machine Learning Summer School, [...]</description>
		<content:encoded><![CDATA[<p>[...]        DeliciousEngadget 4 hours agoFacebook Developers | HipHop for PHP: Move Fast 15 hours agoAutomatically subscribe users to DreamHost announce lists | Edward A. Webb (.com) 15 hours agoAbout PASCAL | PASCAL 2 2010/02/02Cognitive Science and Machine Learning Summer School, [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

