Showing posts with label Web Services. Show all posts
Showing posts with label Web Services. Show all posts

Not Found The requested URL was not found on this server

Sometimes, when you migrate a website from other server to your local server for testing or development and try to run this on browser.

You get an error message like
Not Found
The requested URL was not found on this server
Not Found The requested URL was not found on this server


You check all configurations. Everything is OK in all configuration files of your website. But still you get same error message.

Actually i faced this issue when i run my website on newly installed wamp server. I have searched on google. After spending long time i got a solution and i want to share with you.

It's very simple. I am sharing you two methods. Check which one is working for you.

Method 1.

In apache folder, open httpd.conf file and search following line

#LoadModule rewrite_module modules/mod_rewrite.so

Remove # from the beginning of the line, after removing # line will look like this:

LoadModule rewrite_module modules/mod_rewrite.so


If above method didn't work for you then try method 2.

Method 2.

Change this

Include conf/extra/httpd-vhosts.conf
to

#Include conf/extra/httpd-vhosts.conf
and restart all services


I am sure your issue will be solved...


Read More

How to Make Online Photo Capturing Application Using Flash and PHP

In this tutorial am going to explain how to create a webcam photo capturing application using Flash and PHP. This application works on flash platform. Flash will capture the photo and send to PHP to save it in web directory. I will also explain you the action script used to develop this application.
Online photo capturing application using flash and PHP

Photo capturing application using Flash and PHP
Basically it will create a video and get a bitmap image from it. The JPGE encoder will make it as a jpg image and send it to PHP. PHP will get image from flash using $GLOBALS["HTTP_RAW_POST_DATA"] and save it in a directory.

How to Make Online Photo Capturing Application Using Flash and PHP,Make Online Photo Capturing Application,Online Photo Capturing Application,Photo Capturing Application,Flash and PHP




















  • You can view demo and download the example file below:

Demo                 Download

main code
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import com.adobe.images.JPGEncoder;
    //Sound for the "Capture" button click
    var snd:Sound = new camerasound();
    //Set the maximum amount of bandwidth that the current outgoing video feed can use
    //Should be in bytes per second.
    var bandwidth:int = 0;
    // This value is 0-100 with 1 being the lowest quality.
    var quality:int = 100;
    //Run Camera
    var cam:Camera = Camera.getCamera();
    cam.setQuality(bandwidth, quality);
    //Now setMode(videoWidth, videoHeight, video fps, favor area)
    cam.setMode(320,240,30,false);
    var video:Video = new Video();
    video.attachCamera(cam);
    video.x = 20;
    video.y = 20;
    addChild(video);
    //Image Data
    var bitmapData:BitmapData = new BitmapData(video.width,video.height);
    var bitmap:Bitmap = new Bitmap(bitmapData);
    //Set height and width for image
    bitmap.x = 360;
    bitmap.y = 20;
    addChild(bitmap);
    capture_mc.buttonMode = true;
    //OnClick image captur
    capture_mc.addEventListener(MouseEvent.CLICK,captureImage);
    function captureImage(e:MouseEvent):void {
    snd.play();
    bitmapData.draw(video);
    save_mc.buttonMode = true;
    save_mc.addEventListener(MouseEvent.CLICK, onSaveJPG);
    save_mc.alpha = 1;
    }
    save_mc.alpha = .5;
    function onSaveJPG(e:Event):void{
    var myEncoder:JPGEncoder = new JPGEncoder(100);
    var byteArray:ByteArray = myEncoder.encode(bitmapData);
    var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
    //PHP fle to save the image
    var saveJPG:URLRequest = new URLRequest("save.php");
    saveJPG.requestHeaders.push(header);
    saveJPG.method = URLRequestMethod.POST;
    saveJPG.data = byteArray;
    var urlLoader:URLLoader = new URLLoader();
    urlLoader.addEventListener(Event.COMPLETE, sendComplete);
    urlLoader.load(saveJPG);
    function sendComplete(event:Event):void{
    warn.visible = true;
    addChild(warn);
    warn.addEventListener(MouseEvent.MOUSE_DOWN, warnDown);
    warn.buttonMode = true;
    }
    } 
Now flash captured image will send to save.php. Below is the php script to save this image in a directory. 

Read More

How to Create RSS Reader Using Google Feed API

In this tutorial I’ll tell you how you can do it in pure javascript. Surfing web, I stumbled upon the Google Feed API, and thought that perhaps he would help me in this matter. Because using this service, I can easily (on-fly) to convert XML (of RSS) to JSON format. And as far as we know, javascript can easily work with JSON response. That’s what we will use, and now, lets check online demo.

How to Create RSS Reader Using Google Feed API,Create RSS Reader Using Google Feed API,RSS Reader Using Google Feed API,Google Feed API

index.html
<html>
<head>
<title>New own RSS reader demonstration</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script type="text/javascript" src="js/main.js"></script>
</head>
<body>
<div>
<div id="post_results1" rss_num="8" rss_url="http://rss.news.yahoo.com/rss/topstories">
<div>
<img alt="Loading..." src="images/loading.gif" />
</div>
</div>
<div id="post_results2" rss_num="8" rss_url="http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml">
<div>
<img alt="Loading..." src="images/loading.gif" />
</div>
</div>
<div style="clear:both;"></div>
</div>
<div style="bottom:0;position:fixed;">
<hr style="clear:both;" />
<h4>
<a href="http://techdilute.com/create-rss-reader/">back to original article page</a>
</h4>
</div>
</body>
</html>
main.css
body{background:#eee;margin:0;padding:0}
.example{background:#FFF;width:825px;border:1px #000 solid;margin:20px auto;padding:15px;-moz-border-radius: 3px;-webkit-border-radius: 3px}
.post_results {
margin: 5px;
width: 400px;
border:1px solid #444;
float:left;
}
.post_results ul {
list-style:none;
text-align:left;
padding:0;
margin: 0;
}
.post_results ul li {
background: #555555;
background: -moz-linear-gradient(top, #555555 0%, #444444 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#555555), color-stop(100%,#444444)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #555555 0%,#444444 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #555555 0%,#444444 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #555555 0%,#444444 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#555555', endColorstr='#444444',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, #555555 0%,#444444 100%); /* W3C */
height: 60px;
padding: 10px;
}
.post_results ul li:hover{
background: #666;
}
.post_results ul li a{
color: #fff;
display: block;
font-size: 14px;
font-weight: bold;
text-align: center;
text-decoration: none;
margin-bottom:5px;
}
.post_results ul li a:hover{
color: #eee;
}
.post_results ul li p {
color: #ddd;
font-size: 13px;
margin: 0;
main.js
function myGetElementsByClassName(selector) {
if ( document.getElementsByClassName ) {
return document.getElementsByClassName(selector);
}
var returnList = new Array();
var nodes = document.getElementsByTagName('div');
var max = nodes.length;
for ( var i = 0; i < max; i++ ) {
if ( nodes[i].className == selector ) {
returnList[returnList.length] = nodes[i];
}
}
return returnList;
}
var rssReader = {
containers : null,
// initialization function
init : function(selector) {
containers = myGetElementsByClassName(selector);
for(i=0;i<containers.length;i++){
// getting necessary variables
var rssUrl = containers[i].getAttribute('rss_url');
var num = containers[i].getAttribute('rss_num');
var id = containers[i].getAttribute('id');
// creating temp scripts which will help us to transform XML (RSS) to JSON
var url = encodeURIComponent(rssUrl);
var googUrl = 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num='+num+'&q='+url+'&callback=rssReader.parse&context='+id;
var script = document.createElement('script');
script.setAttribute('type','text/javascript');
script.setAttribute('charset','utf-8');
script.setAttribute('src',googUrl);
containers[i].appendChild(script);
}
},
// parsing of results by google
parse : function(context, data) {
var container = document.getElementById(context);
container.innerHTML = '';
// creating list of elements
var mainList = document.createElement('ul');
// also creating its childs (subitems)
var entries = data.feed.entries;
for (var i=0; i<entries.length; i++) {
var listItem = document.createElement('li');
var title = entries[i].title;
var contentSnippet = entries[i].contentSnippet;
var contentSnippetText = document.createTextNode(contentSnippet);
var link = document.createElement('a');
link.setAttribute('href', entries[i].link);
link.setAttribute('target','_blank');
var text = document.createTextNode(title);
link.appendChild(text);
// add link to list item
listItem.appendChild(link);
var desc = document.createElement('p');
desc.appendChild(contentSnippetText);
// add description to list item
listItem.appendChild(desc);
// adding list item to main list
mainList.appendChild(listItem);
}
container.appendChild(mainList);
}
};
window.onload = function() {
rssReader.init('post_results');
As you can see in index.html– I prepared two DIV elements where going to load RSS feeds, in attributes (rss_url and rss_num) I pointing url of rss feed and amount of elements which going to display and It is rather simple.

When the page loads – I appending prepared javascript objects into our containers (div). That javascript asking google to convers RSS(XML) feed to JSON format using Google Feed API. After, script pass executing to ‘parse’ function of our object, that function convert JSON date into HTML presentation. So, in result – it loading our XML feed in HTML format. All pretty nice
Read More

Get Stock Data From Yahoo Finance in PHP

Welcome in s2ptech here i am giving you new web service for Yahoo Finance in php by which you can easily get stock quote data from Yahoo.
You need to follow some step:
  • Step 1: First of all i am giving you top tech companies data from Yahoo Finance.
  1. For eBay: http://finance.yahoo.com/q?s=EBAY
  2. For Amazon: http://finance.yahoo.com/q?s=AMZN
  3. For Apple: http://finance.yahoo.com/q?s=AAPL
  4. For Microsoft: http://finance.yahoo.com/q?s=MSFT
  5. For Yahoo: http://finance.yahoo.com/q?s=YHOO
You can use for more by finding stock ticker symbol like GOOG for Google, MSFT for Microsoft, APPL for Apple, etc.
  • Step 2: Now i am tell you How can you fetch data from giving url using PHP. You need to make two php file.

yahoofinance.php
<?php
class YahooStock {
     private $stocks = array();
     private $format;
     public function addStock($stock)
    {
        $this->stocks[] = $stock;
    }
     public function addFormat($format)
    {
        $this->format = $format;
    }
     public function getQuotes()
    {      
        $result = array();    
        $format = $this->format;
        
        foreach ($this->stocks as $stock)
        {          
           $s = file_get_contents("http://finance.yahoo.com/d/quotes.csv?s=$stock&f=$format&e=.csv");
                 $data = explode( ',', $s);
                 $result[$stock] = $data;
        }
        return $result;
    }
  • Step 3: Now make another php file


index.php (main php file)
<?php
include_once('yahoofinance.php ');

$objYahooStock = new YahooStock;

/**
    Add format/parameters to be fetched
    
    s = Symbol
    n = Name
    l1 = Last Trade (Price Only)
    d1 = Last Trade Date
    t1 = Last Trade Time
    c = Change and Percent Change
    v = Volume
 */
$objYahooStock->addFormat("snl1d1t1cv");

/**
    Add company stock code to be fetched
    
    msft = Microsoft
    amzn = Amazon
    yhoo = Yahoo
    goog = Google
    aapl = Apple  
 */
$objYahooStock->addStock("msft");
$objYahooStock->addStock("amzn");
$objYahooStock->addStock("yhoo");
$objYahooStock->addStock("goog");
$objYahooStock->addStock("vgz");

/**
 * Printing out the data
 */
foreach( $objYahooStock->getQuotes() as $code => $stock)
{
    ?>
    Code: <?php echo $stock[0]; ?> <br />
    Name: <?php echo $stock[1]; ?> <br />
    Last Trade Price: <?php echo $stock[2]; ?> <br />
    Last Trade Date: <?php echo $stock[3]; ?> <br />
    Last Trade Time: <?php echo $stock[4]; ?> <br />
    Change and Percent Change: <?php echo $stock[5]; ?> <br />
    Volume: <?php echo $stock[6]; ?> <br /><br />
    <?php
}
?>
  •  Step 4: Just run index.php file and thats it.

Note: If you think it is valuable post then please give some time to comment and feel free to give suggestion.
Read More