Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Monday, December 1, 2014

How to make Tweet Auto Bot with PHP?

Leave a Comment


In this post I discuss making auto tweet twitter bot with PHPIn this case you also update your tweet without login to your twitter accout, bot is just to update the tweet so scheduled.

First create apps on twitter here to get a consumer key, consumer secret, the user token and user secret.     then download twitter library of the mat harris here then extract the htdocs folder and then rename it Tweetbot


Create a file tweet.php, for the contents of my tweets using arrays like this bellow:
 >'tweet pertama', 2 =>'tweet kedua', 3 =>'tweet ketiga',  );
 
$f = fopen('data.txt', 'r');
$i = fscanf($f, '%d');
$b = $i[0];
 
require 'tmhOAuth.php';
require 'tmhUtilities.php';
$tmhOAuth = new tmhOAuth(array(
  'consumer_key'    => '', // fill with consumer key
  'consumer_secret' => '', // fill with consumer secret
  'user_token'      => '', // fill with user token
  'user_secret'     => '', // fill with user secret
));
 
$code = $tmhOAuth->request('POST', $tmhOAuth->url('1/statuses/update'), array(
  'status' => "$quote[$b]"
));
 
if ($code == 200) {
  tmhUtilities::pr(json_decode($tmhOAuth->response['response']));
} else {
  tmhUtilities::pr($tmhOAuth->response['response']);
}
 
$f = fopen('data.txt', 'r+' );
$count = fread($f, filesize('data.txt'));
rewind($f);
$count++;
fwrite($f, $count);
ftruncate($f, ftell($f));
fclose( $f );

Then create a file whose contents count.txt useful to be variable repetition. The contents of the file are only numbers. I use to run php cli. how to run it:
         psychology @ cmyk : ~ $ php /opt/lampp/htdocs/tweetbot/tweet.php

Note :  psychology is the name of your username website

Then to the transfers could use crontab, my example will run every hour, on the cronjob on your CPanel :

         * 1 * * * php /opt/lampp/htdocs/tweetbot/tweet.php

Perhaps more friends can develop it further in order to become more attractive as possible by using mysql to tweet or other contents.


Download FULL SOURCE HERE
Read More...

Saturday, October 18, 2014

How to redirect non-www to www with .htaccess

Leave a Comment
Hallo, Good Evening dear,
Today we will learn about "How to redirect non-www to www with .htaccess", in this case for the first word i say is .htaccess.

According to wikipedia.com, .htacces file is a directory-level configuration file supported by several web servers, that allows for decentralized management of web server configuration. They are placed inside the web tree, and are able to override a subset of the server's global configuration for the directory that they are in, and all sub-directories.
The original purpose of .htaccess—reflected in its name—was to allow per-directory access control, by for example requiring a password to access the content. Nowadays however, the .htaccess files can override many other configuration settings including content type and character set, CGI handlers, etc.

If you want to redirect all non-www requests to your site to the www version, all you need to do is add the following code to your .htaccess file, just do it like this :
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This will redirect any requests to http://example.com to http://www.example.com. There are several benefits from doing that:
  • It will avoid duplicate content in Google
  • It will avoid the possibility of split page rank and/or split link popularity (inbound links).
  • It's nicer, and more consistent.
 If you want to do the opposite, the code is very similar, and it's will be spesificate or live respon to your domain like this :
RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]
In this case we are explicitly typing the domain name. I'm sure it's possible to do it in a generic way, but I haven't had the time to work one out and test it. So remember to change 'my-domain' with your domain name.
thank's for read this :)
Read More...

Friday, August 29, 2014

There is no Place like 404 page??

Leave a Comment

What is 404, why not 303?or others number??

Every day if you working on Internet, you will not be foreign to hearing about 404 page not found, this code found for every client who access the page can't be show on website or webpage, or other information that users find out in Internet.
so, we will asking why?, here is some infomation to expalin this code:
HTTP code was developed by the World Wide Web Consortium named Consortiun (W3C) in 1992 as part of the HTTP 0.9 spesifications. They are defined by Tim Berners-Lee, the same man who alone find a web and a web browser the first time in 1990 Berners-Lee likens the HTTP status code with FTP status code, which has existed since 1990; FTP specifications inaugurated on 1985, although FTP has actually been used for much longer.

if we check and analisys that number, 4 (first number of 404) is: we have error on the client side, and 0(on the middle) , mean that the error get found on sintax (page line error), and 4 is show where this error found (what group of this error), it just like archieve on our filling cabinet.

404 also often redirecting on 400 : Bad Reques, 401 : Unauthorized, and etc
all of detail this number you can read on bellow, this code created by  Berners-Lee Team.

Normal Code Response :
  • “100 ; Section 10.1.1: Continue
  • “101 ; Section 10.1.2: Switching Protocols
  • “200 ; Section 10.2.1: OK
  • “201 ; Section 10.2.2: Created
  • “202 ; Section 10.2.3: Accepted
  • “203 ; Section 10.2.4: Non-Authoritative Information 
  • 204 ; Section 10.2.5: No Content
  • “205 ; Section 10.2.6: Reset Content
  • “206 ; Section 10.2.7: Partial Content
  • “300 ; Section 10.3.1: Multiple Choices
  • “301 ; Section 10.3.2: Dipindahkan secara permanent
  • “302 ; Section 10.3.3: Found
  • “303 ; Section 10.3.4: See Other
  • “304 ; Section 10.3.5: Not Modified
  • “305 ; Section 10.3.6: Use Proxy
  • “307 ; Section 10.3.8: Temporary Redirect

Server Error Side :
  • “200 ; Section 10.2.1: OK
  • “201 ; Section 10.2.2: Created
  • “202 ; Section 10.2.3: Accepted
  • “203 ; Section 10.2.4: Non-Authoritative Information
  • “204 ; Section 10.2.5: No Content
  • “205 ; Section 10.2.6: Reset Content
  • “206 ; Section 10.2.7: Partial Content
 Client Error Side:
  • 400 ; Section 10.4.1: Bad Request / Permintaan: Buruk
  • “401 ; Section 10.4.2: Unauthorized
  • “402 ; Section 10.4.3: Payment Required / Pembayaran Dibutuhkan
  • “403 ; Section 10.4.4: Forbidden
  • “404 ; Section 10.4.5: Not Found
  • “405 ; Section 10.4.6: Method Not Allowed
  • “406 ; Section 10.4.7: Not Acceptable
  • “407 ; Section 10.4.8: Proxy Authenti ation Required
  • “408 ; Section 10.4.9: Request Timeout
  • “409 ; Section 10.4.10: Conflict
  • “410 ; Section 10.4.11: Gone
  • “411 ; Section 10.4.12: Length Required
  • “412 ; Section 10.4.13: Precondition Failed
  • “413 ; Section 10.4.14: Request Entity Too Large
  • “414 ; Section 10.4.15: Request-URI Too Large
  • “415 ; Section 10.4.16: Unsupported Media Type
  • “416 ; Section 10.4.17: Requested range not satisfiable
  • “417 ; Section 10.4.18: Expectation Failed
  • “500 ; Section 10.5.1: Internal Server Error
  • “501 ; Section 10.5.2: Not Implemented
  • “502 ; Section 10.5.3: Bad Gateway
  • “503 ; Section 10.5.4: Service Unavailable
  • “504 ; Section 10.5.5: Gateway Time-out
  • “505 ; Section 10.5.6: HTTP Version not supported
we think that after read this article, you maybe know why must be 404?, and why not should other numbers, thanks for read!

Read More...