PHP – Get page links (using the DOMDocument)

PHP has a very useful library – The DOM Document. Using this you’ll be able to get the source code of a page and go through each element of the HTML filtering out what you need and don’t need, If you’re using this for scraping websites for information the DOMDocument library is invaluable.

Below I will be showing you how to get the source code of an external website and return an array of links.

Read More

PHP – Posting to Twitter (using OAuth)

Twitter has now moved over to OAuth (no longer supporting Basic Auth) – You’re now forced to use this when wanting to post/retrieve information using a Twitter account and Twitter Application. Since searching around I haven’t found any good examples of how to post a Tweet to twitter using the Twitter REST API.

I will be using a third party library as an example and creating an wrapper class to set it up and use it, all you’ll have to do is include a file and a few lines of code to get started. Before we proceed you’ll need to download the Twitter OAuth API from GitHUB by Clicking Here which is developed by Abraham Williams.

Read More

PHP – cURL Example Class

cURL is a very powerful command line tool for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos…), file transfer resume, proxy tunneling and a busload of other useful tricks.

In this post I’ll be showing you a basic class I put together to be used with PHP – It’ll allow you to fetch the source code, info and headers of a remote website.

Read More