久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

上傳遠程照片到上傳

Upload a remote photo to an upload(上傳遠程照片到上傳)
本文介紹了上傳遠程照片到上傳的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

是否可以使用 Facebook PHP 庫將遠程圖片上傳到 Facebook??

Is it possible to upload a remote picture to Facebook using the Facebook PHP Library??

代替使用

    $facebook->setFileUploadSupport(true);
    $args = array('message' => 'My Caption');
    $args['image'] = '@' . realpath($file);

    $data = $facebook->api('/me/photos', 'post', $args);

代替 realpath($file) 我想使用圖像的遠程路徑,例如:

Instead of a realpath($file) I would like to use a remote path to an image for example:

http://myserver.com/image.jpg

我嘗試用 http 鏈接替換 ??realpath($file),但出現以下錯誤:

I tried to replace the realpath($file) with a http link but I got the following error:

 Uncaught CurlException: 26: couldn't open file "http://mydomain.com/fb_images/EwrTsUqEuG.jpg"

推薦答案

使用 file_get_contents() 將文件下載到您的服務器,然后 file_put_contents() 將其存儲在一個臨時的本地文件中,用于上傳 FB 傳輸過程,然后 unlink() 之后刪除文件.

Use file_get_contents() to download the file to your server, then file_put_contents() to store it in a temporary, local file for the upload FB transfer process, then unlink() to delete the file afterwards.

<?php

# The URL for the Image to Transfer
$imageURL = 'http://server.com/the_image.jpg';
# Folder for Temporary Files
$tempFilename = $_SERVER['DOCUMENT_ROOT'].'/tempFiles/';

# Unique Filename
$tempFilename .= uniqid().'_'.basename( $imageURL );

# Get the Image
if( $imgContent = @file_get_contents( $imageURL ) ){
  if( @file_put_contents( $tempFilename , $imgContent ) ){

    $facebook->setFileUploadSupport(true);
    $args = array('message' => 'My Caption');
    $args['image'] = '@' . realpath( $tempFilename );

    $data = $facebook->api('/me/photos', 'post', $args);

    # Once done, delete the Temporary File
    unlink( $tempFilename );

  }else{
    # Failed to Save Image
  }
}else{
  # Failed to Get Image
}

這篇關于上傳遠程照片到上傳的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 日本aa毛片a级毛片免费观看 | 久久久久亚洲精品 | 中文久久 | 午夜精品久久久久久久久久久久久 | 亚洲性人人天天夜夜摸 | 欧美精品免费观看二区 | 久久机热 | 精品一区二区三区不卡 | 亚洲国产成人在线 | www日本在线 | 久久精品久久久 | 美女久久视频 | 欧美一级黄色片 | 久久国产精品-国产精品 | 中文字幕日韩一区二区 | 成av在线| 国产日韩久久 | 亚洲精品一区在线 | 午夜男人的天堂 | 亚洲国产精品久久久久秋霞不卡 | av特级毛片 | 欧美在线观看一区二区 | www.亚洲一区二区三区 | 在线视频亚洲 | 毛片一级片 | 中文在线播放 | 午夜激情影院 | 黄色一级片在线播放 | 国产综合精品一区二区三区 | 亚洲国产精品久久久 | 在线观看国产视频 | 中文字幕在线免费观看 | 日韩精品一区二区三区中文在线 | 一区二区三区欧美在线 | 九九久久国产 | 欧美国产精品一区二区三区 | 欧美日本韩国一区二区 | 我要看免费一级毛片 | 亚洲欧美日韩电影 | 亚洲精品一区二区冲田杏梨 | 日本不卡一区二区三区在线观看 |