문제

Sorry, this might be pretty basic. I'm trying to use the Yelp API and am running a test search for McDonalds in Baltimore.

this is the code:

<?php

    $AccountKey = "XXXX";
    $restaurant = "McDonalds";
    $city = "Baltimore";

    $file = "test.txt";

    $data = http_get("http://api.yelp.com/business_review_search?term=".$restaurant."&location=".$city."&ywsid=".$AccountKey);

    file_put_contents($file, $data);

 ?>

I'm trying to store the results in test.txt which I can then parse but its not working. Any ideas?

Thanks in advance!

도움이 되었습니까?

해결책

In your code you didn't open the text file.

// Open the file to get existing content
$data = file_get_contents($file);
$data. = http_get("http://api.yelp.com/business_review_search?term=".$restaurant."&location=".$city."&ywsid=".$AccountKey);
// Write the contents back to the file
file_put_contents($file, $data);

more details

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top