jacquagnui / php-twitter

Automatically exported from code.google.com/p/php-twitter
0 stars 0 forks source link

suggestion: Set header #56

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
If I set type as xml, json, rss or atom can send this output directly to
the browser (as a proxy). Therefore, I must tell the browser the header
respective

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by falci....@gmail.com on 23 Apr 2010 at 2:53

GoogleCodeExporter commented 8 years ago
Sorry, I accidentally sent.
I suggest this method:

        /**
         * Function to create the response header
         * @author Falci <falci@falci.me>
         * @param string $charset Charset. For example: UTF-8, ISO-8859-1. Default: UTF-8
         * @return bool False if the type is not known, true for all other cases
         */
        function setHeader($charset="UTF-8"){
            switch ($this->type) {
                case "atom":
                    header("Content-type: application/atom+xml; charset=$charset");
                    break;
                case "json":
                    header("Content-type: application/json; charset=$charset");
                    break;
                case "xml":
                    header("Content-type: text/xml; charset=$charset");
                    break;
                case "rss":
                    header("Content-type: application/rss+xml; charset=$charset");
                    break;

                default:
                    return false;
                    break;
            }

            return true;
        }

Original comment by falci....@gmail.com on 23 Apr 2010 at 3:07