Browsing all articles tagged with php
Jul
2

Spin Rewriter now recognizes even the weirdest encodings

You might have noticed I picked the “Programming” category for this blog post. The reason for this is quite simple – this post won’t be very interesting to 95% of you who aren’t programmers. 😉

You see, out of thousands of active users, we have received about 2-3 customer tickets each month saying that Spin Rewriter somehow garbled up the original text. We’ve been looking into this for a while now, and we found out that:

  • 99.5% of all submitted texts are processed normally
  • texts that begin with the bytecode EF BB BF are encoded in the standard UTF-8 format (works well with Spin Rewriter)
  • texts that begin with the bytecode FE FF are encoded in the UTF-16/UCS-2, little endian format (some issues)
  • texts that begin with the bytecode FF FE are encoded in the UTF-16/UCS-2, little endian format (some issues)
  • texts that begin with the bytecode FF FE 00 00 are encoded in the UTF-16/UCS-2, little endian format (sporadic issues)
  • texts that begin with the bytecode 00 00 FE FF are encoded in the UTF-16/UCS-2, little endian format (sporadic issues)

For instance, if our user entered “It іs nevеr a сonvenіent timе tо hаvе уour vеhicle quіt оn уоu.” in the UTF-16/UCS-2, little endian format, Step 2 of the spinning process appeared fine, however Step 3 showed this: “It Ñ�s nevеr a Ñ�onvenÑ�ent timе tо hаvе Ñ�our vеhicle quÑ�t оn Ñ�оu.”

We have now resolved all these issues and Spin Rewriter will process all articles that you can throw at it. 😉

Dec
13

Spin Rewriter API documentation

Okay, we just launched the Spin Rewriter API, and we thought – we should get developers on board as effortlessly as possible!

So we prepared a ton of stuff for all of you developers out there, and our efforts should enable you to integrate the Spin Rewriter API into your own apps in 10 minutes or so. Among other things you’ll find:

  • A thorough documentation of all API (HTTP POST) requests and API (JSON) responses. This will give you an idea about the inner workings of our API.
  • 100% functioning code samples (in PHP):
    – a script that will get the remaining number (quota) of API calls
    – a script that will spin your article and return the spun text (with spintax in place)
    – a script that will spin your article and return one of the possible unique variations
  • We prepared an actual official Spin Rewriter API SDK (Standard Development Kit) that’s also available in PHP. This kit comes with a number of examples, and allows you to spin your articles using the Spin Rewriter API with as little as 3 lines of code. 😉
  • A short “Q&A” section that should provide the answers to the most common questions.

You can find everything over at http://www.SpinRewriter.com/api 😀

We love developers just as much as Steve Ballmer (the Microsoft guy), and we want to make everything as easy as possible for you. Oh, and here’s a funny clip of him going just a little bit crazy. 😀

Dec
7

Spin Rewriter API up & running, we’re almost there!

Yup, that’s right!

Spin Rewriter API  version 1.0 is up and running, supposedly all functionality has been finished and polished, and it’s being stress-tested at the moment.

While we’re performing these final tests, we’re also writing the documentation for all of you developers out there – this way it will be extremely easy to integrate Spin Rewriter with your apps! We decided to go the extra mile and even provide fully functional code samples, as well as a Spin Rewriter SDK for the most experienced developers (at the beginning all this code will be available in PHP, however the basic principles are the same across all programming languages).

We are realistically expecting experienced developers to be able to fully integrate their app with the Spin Rewriter API in less than 15 minutes. And that’s quite a promise, we’re sure you agree! 😀

Nov
29

Spin Rewriter API coming out later this week!

Yes, that’s right!

We’re releasing the official Spin Rewriter API later this week. I lost count after we received something like 400 requests for an API to be added, and we’ve been working on it for almost 2 months now, so it should be pretty good. 😀

What does this mean? It means that sooner or later you will find Spin Rewriter integrated in all your favorite internet marketing applications such as SEnuke, WP Robot, etc. All you will have to do is enter your Spin Rewriter username and password within another application and this application will be able to use your Spin Rewriter account to automatically produce unique high quality content on your behalf.

We can’t wait to see what all those creative devs do with our API … so stay tuned! 😀

Nov
28

Spin Rewriter is FAST (once again), hooray!

You might have noticed that Spin Rewriter was a bit slow at times during these last couple of days … there’s a number of reasons for that, but – in the end – we reached our goal and made it faster than ever! 😀

The response of the Internet Marketing community has exceeded our wildest expectations, and Spin Rewriter is growing at a rate of hundreds of new users per week, which means we’re constantly upgrading our server-grid specs, tweaking settings and optimizing algorithms to make sure it works well for everyone. We finished a big part of this project about 40 hours ago, and the results that we’re seeing are amazing:

  • average server load dropped over 70%
  • 85% of all requests are now handled immediately, i.e. within 0.5 seconds (!)
  • 15% of all requests are waiting on average less than 1.5 seconds before being fully processed by our server
  • this makes the Spin Rewriter web app one of the fastest web applications available today!

We hope you love the new “snappy” Spin Rewriter, and we’ll keep on working hard to make sure you’re satisfied with us in the future as well! 😀

Jun
4

Creating an array of all dates between 2 specified dates [PHP]

Author Aaron    Category Programming     Tags , ,

I’ll just cut to the chase.

/**
 * create an array of all dates between two specified dates
 * @param datetime $strDateFrom
 * @param datetime $strDateTo
 * @return array
 */
function createDateRangeArray($strDateFrom, $strDateTo) {		
	$aryRange = array();
	$iDateFrom = mktime(1, 0, 0, substr($strDateFrom, 5, 2), substr($strDateFrom, 8, 2), substr($strDateFrom, 0, 4));
	$iDateTo = mktime(1, 0, 0, substr($strDateTo, 5, 2), substr($strDateTo, 8, 2), substr($strDateTo, 0, 4));
	if ($iDateTo >= $iDateFrom) {
		array_push($aryRange, date("Y-m-d", $iDateFrom));			
		while ($iDateFrom < $iDateTo) {
			$iDateFrom = $iDateFrom + 86400;
			array_push($aryRange, date("Y-m-d", $iDateFrom));
		}
	}
	return $aryRange;
}
May
8

Is this a valid URL? [PHP]

Author Aaron    Category Programming     Tags , ,

If your users link to some URL, it’s always nice to check if their input actually represents a valid URL. You can do just that with this function:


/**
 * return true if the passed variable is a valid URL address
 * @param $url
 * @return boolean
 */
function isValidURL($url) {
	$pattern  = '/^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/';
	return preg_match($pattern, $url);
}

If this function returns true, you might want to actually open the URL (using file_get_contents() or some other function) to see if it works.

Apr
23

Convert large numbers into a more readable format

Author Aaron    Category Programming     Tags , ,

It can be tricky to really understand the value of 7312946 or 983217 at the first glance. Saying 7.3M and 983k seems like a much better option. How to convert numbers into a nicer format? Like this:

/**
 * create a nicely formatted number
 * @param $number a large number
 * @param $shorten default true = append k or M, false = format with commas and dots
 * @return int
 */
function createHumanReadableInteger($number, $shorten = true) {
	if (is_numeric($number)) {
		if ($shorten) {
			if ($number < 100000) {
				$return_int = number_format($number, 0);
			} else {
				$number_proc = $number;
				$units = explode(" ", "B k M G T P");
				for ($i = 0; $number_proc > 1000; $i++) {
					$number_proc = $number_proc / 1000;
				}
				if ($number > 1000000) {
					$return_int = round($number_proc, 2) . " " . $units[$i];
				} else {
					$return_int = round($number_proc, 1) . " " . $units[$i];	
				}
			}
		} else {
			$return_int = number_format($number, 0);
		}
		return $return_int;	
	} else {
		return 0;
	}
}
Mar
25

Converting a DATETIME variable into a UNIX timestamp

Author Aaron    Category Programming     Tags , ,

Here’s how:

/**
 * convert a datetime value (Y-m-d H:i:s) to UNIX timestamp value
 * @param datetime $datetime
 * @return timestamp
 */
function datetime_to_timestamp($datetime) {
    list($date, $time) = explode(" ", $datetime);
    list($year, $month, $day) = explode("-", $date);
    list($hour, $minute, $second) = explode(":", $time);
    return mktime($hour, $minute, $second, $month, $day, $year);
}
Mar
19

Using subkey to sort an array in PHP

Author Aaron    Category Programming     Tags , ,

It’s a bit tricky to sort multidimensional arrays in PHP by one of array’s subkeys, but it can absolutely be done. Check it out:

/**
 * USING POINTER TO ARRAY - sort an array of arrays with associative indeces by one of those associative values
 * @param $array pointer to our array
 * @param $subkey associative index that we want to order by
 * @param $sort_type [SORT_ASC|SORT_DESC]
 * @return void
 */
function sortBySubkey(&$array, $subkey, $sort_type = SORT_ASC) {
   foreach ($array as $subarray) {
      $keys[] = $subarray[$subkey];
   }
   array_multisort($keys, $sort_type, $array);
}
Follow me on Twitter! Follow me on Twitter!
You can always stay up-to-date with our latest and craziest projects ...

Categories:

Monthly Archives:

I mostly write about:

Who is Aaron?

I'm a guy who started his own successful online business back in 2007. I was lucky enough to see my business expand 300+% every year.

At the moment my team and I reach over a million unique customers each month and always do our best to deliver the best quality services.