input: Write a function to scrape photos and captions from a given website using BeautifulSoup and requests libraries. The function should return the photos and their captions as a list of dictionaries, where each dictionary contains the keys 'photo' and 'caption'. If there is no caption for a photo, the 'caption' key should be an empty string. If the provided URL is invalid, the function should return an empty list.
  
  assert scrape_photos_and_captions('https://example.com/webpage')==[{'photo': 'https://example.com/photo1.jpg', 'caption': 'First photo caption'}, {'photo': 'https://example.com/photo2.jpg', 'caption': ''}]
  assert scrape_photos_and_captions('https://invalid-url')==[]
output: import requests
  from bs4 import BeautifulSoup
  
  def scrape_photos_and_captions(url):
      try:
          response = requests.get(url)
          response.raise_for_status()
      except:
          return []
      
      soup = BeautifulSoup(response.text, 'html.parser')
      photos_and_captions = []
      
      for img in soup.find_all('img'):
          photo_url = img.get('src')
          caption = img.find_next('figcaption').text.strip() if img.find_next('figcaption') else ''
          photos_and_captions.append({'photo': photo_url, 'caption': caption})
      
      return photos_and_captions