问题
I want to post an image on twitter but I can't. I am able to post only text message with twitter API.
The error is: Error: Server error: couldn't open file "Capture.png"
I use wamp server. The picture is in the same folder with the script.
Where is the problem?
require_once '../src/twitter.class.php';
// ENTER HERE YOUR CREDENTIALS (see readme.txt)
$twitter = new Twitter. ('raQBedybFLb', 'HWgN6Qt11jg0LY', '862846056-ndeGfMA83r9ldh', 'VMBvHDahXnGp');
$p='./Capture.png';
try {
$tweet = $twitter->send('testing twitter api', $p); // you can add $imagePath as second argument
} catch (TwitterException $e) {
echo 'Error: ' . $e->getMessage();
}
回答1:
You may use $p = realpath('Capture.png');
来源:https://stackoverflow.com/questions/24274039/error-server-error-couldnt-open-file-capture-png