php kullanarak json olsun

2 Cevap php

I need to get the json data from, http://vortaro.us.to/ajax/epo/eng/ + 'word'+ "/?callback=?" working example (not enough reputation)

Javascript bunu nasıl biliyorum, Ama ben, bu sunucu tarafı olması gerekiyor, bu verileri almak için ben bu anlamaya çalışırken bütün gün geçirdim yeniyim Teşekkürler benim php dosyası gerekir. fopen ve fread çalışmıyor,

<?php
$vorto = $_GET['vorto']; // Get the Word from Outer Space and Search for it!

if (isset($vorto))
    {
    echo $vorto;
    } else {
        $Help = "No Vorto -> add ?vorto=TheWordYouWant to the end of this website";
        echo $Help;
    }
$url1 = "http://vortaro.us.to/ajax/epo/eng/"; 
$url2 = "/?callback=?";
$finalurl= $url1 . $vorto . $url2;

/*
PLEASE HELP

$v1 = fopen($finalurl ,"r");
echo $v1;


$frv1 = fread($v1,filesize($v1));
echo $frv1 ;

*/

?>

2 Cevap

file_get_contents() URL kullanılabilir. Http sayfa indirme işlemek için basit ve kolay bir yoludur.

Yani yapıldı, json_decode() kullanışlı bir veri ayrıştırmak için kullanabilirsiniz.

PHP Curl bir göz atın.

Bu örnekte ile tüm bilgiler edebiliyoruz.

<?php
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);
?>

PHP Curl php.ini olanak olduğundan emin olun. Eğer ayar allow_url_fopen fopen kullanmak istiyorsanız php.ini 'AÇIK' olmalıdır. Tüm ayarları için Ödeme phpinfo ().

PHP işlevi 5.2.0 yana json_decode çekirdek kısmının bir parçasıdır.