francis Aneke Posted April 7, 2014 Share Posted April 7, 2014 I need the widget to be in my website. Any easy way that i can walk around to embed a widget inside my web can help Link to comment Share on other sites More sharing options...
thescientist Posted April 7, 2014 Share Posted April 7, 2014 widget is a very vague and generic term. you should be specific in what exactly you are trying to do. Link to comment Share on other sites More sharing options...
francis Aneke Posted April 7, 2014 Author Share Posted April 7, 2014 well, i want to display daily news from a website to my webpage such as yahoo news. And i would like to display it in the very size(width and height) that i want them Link to comment Share on other sites More sharing options...
thescientist Posted April 8, 2014 Share Posted April 8, 2014 ok. so what website? How are you going to get the data? If it's on a different domain, likely you will need to create a proxy script in PHP that will make the request for you, and then return the data. Javascript could make the request to the script using AJAX, which just returns the data, then you can style and position that data anyway you want. 1 Link to comment Share on other sites More sharing options...
francis Aneke Posted April 9, 2014 Author Share Posted April 9, 2014 please, thescientist, don't say that am asking to much... can you just give me a hint on how to create a proxy script in PHP that will make the request for me, and then return the data. Link to comment Share on other sites More sharing options...
thescientist Posted April 10, 2014 Share Posted April 10, 2014 It's simply a php script that you make a (AJAX) request to whatever you need to make a request to. One option is to use the cURL library for PHP. http://codular.com/curl-with-php https://php.net/curl Link to comment Share on other sites More sharing options...
justsomeguy Posted April 10, 2014 Share Posted April 10, 2014 Here's one such proxy script:http://benalman.com/code/projects/php-simple-proxy/docs/files/ba-simple-proxy-php.htmlIf you're trying to get data with Javascript from a different domain then you need to use a proxy because Javascript cannot send a request to a different domain. So Javascript sends a request to the PHP file on your server, PHP sends the request to the other domain, gets the content, and returns it to Javascript. 1 Link to comment Share on other sites More sharing options...
francis Aneke Posted April 11, 2014 Author Share Posted April 11, 2014 <!----Thescientist and Justomeguy....After researching base on what you gave me i came up with this script//////////////////////////////////////////////////////////////////////////---><?php$url = "http://yahoo.com/news";$proxy_port = 80;$timeout = 0;$referer = "http://www.mysite/page.php";$proxy ="92.105.140.115";$curl_result=$curl_err='';$ch = curl_init();curl_setopt($ch, CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_HEADER,1);curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);curl_setopt($ch, CURLOPT_PROXYPORT,$proxy_port);curl_setopt($ch, CURLOPT_PROXY,$proxy);curl_setopt($ch, CURLOPT_PROXYTYPE,'HTTP');curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL,0);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);curl_setopt($ch, CURLOPT_REFERER,$referer);curl_setopt($ch, CURLOPT_VERBOSE, 1);$curl_result = @curl_exec($ch);$curl_err = curl_error($ch);curl_close($ch);?><?php///output and styling goes hereecho $curl_result;?><!------//////////////////////////////////////////////////////////////////But i dont know if what i have is done ok or not2)Am i suppose to put the full URL path of the website i want to fetch the data($url = "http://yahoo.com/news/page.asp or whatever";)3) Also am i suppose to make a full path of my website page to return the reguest($referer = "http://www.mysite/page.php";)4) should i echo the script if not what should i do5) well am still designing the website so i guess the $proxy_port and $proxy is undefined or am i messing around, if i am, please what should i do? finally if am geting it well, what if there is a particular meassage(eg daily news) on a particular portion(<div>) of the website page that i want to grab, what should i do......that is if i dont want to grab every thing on that page {FORGIVE ME FOR THE TOO MUCH QUESTIONS}--------> Link to comment Share on other sites More sharing options...
francis Aneke Posted April 11, 2014 Author Share Posted April 11, 2014 <!---- Thescientist and Justomeguy.... After researching base on what you gave me i came up with this script ////////////////////////////////////////////////////////////////////////// ---> <?php $url = "http://yahoo.com/news"; $proxy_port = 80; $timeout = 0; $referer = "http://www.mysite/page.php"; $proxy ="92.105.140.115"; $curl_result=$curl_err=''; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_HEADER,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,0); curl_setopt($ch, CURLOPT_PROXYPORT,$proxy_port); curl_setopt($ch, CURLOPT_PROXY,$proxy); curl_setopt($ch, CURLOPT_PROXYTYPE,'HTTP'); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL,0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_REFERER,$referer); curl_setopt($ch, CURLOPT_VERBOSE, 1); $curl_result = @curl_exec($ch); $curl_err = curl_error($ch); curl_close($ch); ?> <?php ///output and styling goes here echo $curl_result; ?> <!------////////////////////////////////////////////////////////////////// But i dont know if what i have is done ok or not 2)Am i suppose to put the full URL path of the website i want to fetch the data($url = "http://yahoo.com/news/page.asp or whatever";) 3) Also am i suppose to make a full path of my website page to return the reguest($referer = "http://www.mysite/page.php";) 4) should i echo the script if not what should i do 5) well am still designing the website so i guess the $proxy_port and $proxy is undefined or am i messing around, if i am, please what should i do? finally if am geting it well, what if there is a particular meassage(eg daily news) on a particular portion(<div>) of the website page that i want to grab, what should i do......that is if i dont want to grab every thing on that page {FORGIVE ME FOR THE TOO MUCH QUESTIONS} --------> Link to comment Share on other sites More sharing options...
thescientist Posted April 11, 2014 Share Posted April 11, 2014 there were some very basic examples provided on the cURL page. why don't you start with that and see what you get. http://www.php.net/manual/en/curl.examples-basic.php as far as parsing the DOM, there are built in libraries in PHP you should be able to use http://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php also, dont use @ sign in code. It suppresses errors, which is bad thing. If there are errors, you should want to know about them and fix / handle them. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 11, 2014 Share Posted April 11, 2014 If you're trying to display content from other sites then you will probably want to use the services they provide. Yahoo, for example, has RSS feeds for its various services:https://developer.yahoo.com/rss/You can get the RSS feed for Yahoo News and it will return a list of stories with headlines and links or whatever else. Once you have the RSS data then there are several ways to parse it to get the different pieces of content.https://www.google.com/search?client=opera&q=php+parse+rrss&sourceid=opera&ie=UTF-8&oe=UTF-8#q=php+parse+rss&spell=1 Link to comment Share on other sites More sharing options...
francis Aneke Posted April 21, 2014 Author Share Posted April 21, 2014 (edited) WELL, after many days of searching and learning the contents in the link both of you gave me, i came up with what i have been looking for which is right here with us on the learning page, at the XML and AJAX-PHP page. Then i have learnt how i can parse any RSS feed(what i want is called rss feed as i have learnt) from any website that provided their feeds for developers be it youtube. TED, google etc. I found out that i can achieve this using php DOM where by i can use xmlload function to load the url, view the imported nodes i want to parse and then refer to the nodes and then display their content the way i want them. The ajax-php page helped alot and the links to stackoverflow->http://stackoverflow...html-xml-in-php....... helped This link by JustOmeGuy, will also help https://developer.yahoo.com/rss/ because its where i will be geting the url of xml page for parsing them to my web. THANKS guys, i learnt a lot but i still need you guys for future trouble....... THANKS Edited April 21, 2014 by francis Aneke Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now