{"action":"closed","issue":{"url":"https://api.github.com/repos/facebook/facebook-php-sdk-v4/issues/464","labels_url":"https://api.github.com/repos/facebook/facebook-php-sdk-v4/issues/464/labels{/name}","comments_url":"https://api.github.com/repos/facebook/facebook-php-sdk-v4/issues/464/comments","events_url":"https://api.github.com/repos/facebook/facebook-php-sdk-v4/issues/464/events","html_url":"https://github.com/facebook/facebook-php-sdk-v4/issues/464","id":93633800,"number":464,"title":"Upload Photo - Facebook (post) request error: (#324) Requires upload file","user":{"login":"tatters1979","id":1915928,"avatar_url":"https://avatars.githubusercontent.com/u/1915928?v=3","gravatar_id":"","url":"https://api.github.com/users/tatters1979","html_url":"https://github.com/tatters1979","followers_url":"https://api.github.com/users/tatters1979/followers","following_url":"https://api.github.com/users/tatters1979/following{/other_user}","gists_url":"https://api.github.com/users/tatters1979/gists{/gist_id}","starred_url":"https://api.github.com/users/tatters1979/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tatters1979/subscriptions","organizations_url":"https://api.github.com/users/tatters1979/orgs","repos_url":"https://api.github.com/users/tatters1979/repos","events_url":"https://api.github.com/users/tatters1979/events{/privacy}","received_events_url":"https://api.github.com/users/tatters1979/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-07T21:30:37Z","updated_at":"2015-07-17T17:10:10Z","closed_at":"2015-07-17T17:10:10Z","body":"Hi, I've just started to use the Facebook SDK php and login, retrieving a user's profile and posting links is working fine, however posting photos is not working no matter what I try.\r\n\r\nFacebook (post) request error: (#324) Requires upload file is the error I get.\r\n\r\nI've tried 'source' => new CURLFile('path/to/file.name', 'image/png') with various different locations for the image (even in the root), 'source' => '@/path/to/file.name' even though I'm using the correct php library, and even from a site link but still no luck?\r\n\r\nI'd like user to be able to use $_FILES['img']['tmp_name'] so users can upload multiple images/photos themselves from a form but I can't seem to get a fixed image/photo to work? \r\n\r\nAny help/guidance would be great.\r\n\r\n    <?php\r\n    session_start();\r\n\r\n    require_once 'facebook/autoload.php';\r\n    use Facebook\\FacebookRequest;\r\n    use Facebook\\GraphObject;\r\n    use Facebook\\FacebookRequestException;\r\n    use Facebook\\FacebookSession;\r\n    use Facebook\\GraphUser;\r\n    use Facebook\\FacebookRedirectLoginHelper;\r\n\r\n    $api_key = 'XXXXXXXXXXX';\r\n    $api_secret = 'XXXXXXXXXXX';\r\n    $redirect_login_url = 'XXXXXXXXXXXX';\r\n\r\n    $message = $_POST['mess'];\r\n\r\n    FacebookSession::setDefaultApplication($api_key, $api_secret);\r\n\r\n    $helper = new FacebookRedirectLoginHelper( $redirect_login_url);\r\n\r\n    // First check if this is an existing PHP session\r\n    if ( isset( $_SESSION ) && isset( $_SESSION['fb_token'] ) ) {\r\n\t// create new session from the existing PHP sesson\r\n\t$session = new FacebookSession( $_SESSION['fb_token'] );\r\n\ttry {\r\n\t\t// validate the access_token to make sure it's still valid\r\n\t\tif ( !$session->validate() ) $session = null;\r\n\t} catch ( Exception $e ) {\r\n\t\t// catch any exceptions and set the sesson null\r\n\t\t$session = null;\r\n\t\techo 'No session: '.$e->getMessage();\r\n\t}\r\n    }  elseif ( empty( $session ) ) {\r\n\t// the session is empty, we create a new one\r\n\ttry {\r\n\t\t// the visitor is redirected from the login, let's pickup the session\r\n\t\t$session = $helper->getSessionFromRedirect();\r\n\t} catch( FacebookRequestException $e ) {\r\n\t\t// Facebook has returned an error\r\n\t\techo 'Facebook (session) request error: '.$e->getMessage();\r\n\t} catch( Exception $e ) {\r\n\t\t// Any other error\r\n\t\techo 'Other (session) request error: '.$e->getMessage();\r\n\t}\r\n    }\r\n    if ( isset( $session ) ) {\r\n\t// store the session token into a PHP session\r\n\t$_SESSION['fb_token'] = $session->getToken();\r\n\t// and create a new Facebook session using the cururent token\r\n\t// or from the new token we got after login\r\n\t$session = new FacebookSession( $session->getToken() );\r\n\r\n\t\ttry {\r\n\t\t// with this session I will post a message to my own timeline\r\n\t\t$request = new FacebookRequest(\r\n\t\t\t$session, \r\n\t\t\t'POST', \r\n\t\t\t'/me/photos', \r\n\t\t\tarray(\r\n\t\t\t\t'source' => '?????',\r\n\t\t\t\t'message' => $message\r\n\t\t\t)\r\n\t\t);\r\n\t\t$response = $request->execute();\r\n\t\t$graphObject = $response->getGraphObject();\r\n\t\t// the POST response object\r\n\t\techo '<pre>' . print_r( $graphObject, 1 ) . '</pre>';\r\n\t\t$msgid = $graphObject->getProperty('id');\r\n\t} catch ( FacebookRequestException $e ) {\r\n\t\t// show any error for this facebook request\r\n\t\techo 'Facebook (post) request error: '.$e->getMessage();\r\n\t}\r\n\r\n    } else {\r\n\t// we need to create a new session, provide a login link\r\n\techo 'No session, please <a href=\"'. $helper->getLoginUrl( array( 'publish_actions' )\r\n    ).'\">login</a>.';\r\n    }\r\n\r\n\r\n\r\n"}}