php


How to create facebook page with PHP or CURL?


I have tested the code and it doesn't work.
This is my code to create the Facebook page, but it doesn't work (appId and secret are valid..).
Here is my actual code:
$facebook = new Facebook(array(
'appId' => FB_APPID,
'secret' => FB_SKEY,
'cookie' => true,
'allowSignedRequest' => false
));
$t = $facebook->getAccessToken();
$file = 'A0HM1-800.png';
$arrData = array(
'name' => 'Test Event',
'start_time' => '2015-07-04', //ISO-8601 format - With Time - 2012-07-04T19:00:00-0700
//'end_time' => '', //optional
'description' => 'Lvsty do Test-Event',
'location' => 'Lvstydo', //Just a name
'location_id' => '103091806397289', //place id - inserts a link to place fb page
'ticket_url' => 'url', //URL to buy a ticket for the event
'no_feed_story' => FALSE, //TRUE = dont display on page
'access_token' => $t,
'picture' => '#'. realpath($file),
);
$createUrl = 'https://graph.facebook.com/page_id/events';
$test = fbcurl($createUrl, 'POST', $arrData); //Returns the event id
echo '<pre>';
print_r($test);
echo '</pre>';
function fbcurl($url, $method, $fields = array(), $auth = array()){
foreach($fields as $key => $value){
if(!is_string($value)){
$fields[$key] = json_encode($value);
}
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:multipart/form-data'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
if(count($fields)>0){
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields, null, '&'));
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$r = curl_exec($ch);
curl_close($ch);
if($r!=''){
$p = explode("\r\n\r\nHTTP/", $r);
$p = (count($p) > 1 ? 'HTTP/' : '') . array_pop($p);
list($h, $b) = explode("\r\n\r\n", $p, 2);
return array('header' => $h, 'body' => $b);
}else{
return array('header' => '', 'body' => 'error');
}
}
Error:
Where is the error? I can't find it..

Related Links

Why should I be using testing frameworks in PHP?
How to select last row of mysql_query?
How to format Zend_db Rowset output?
Google Docs API list of documents and two folders with same name
Why am I getting 'access denied for user' error in php?
Is it possible to send parameters by using Header function?
Tracking function instances
WHats the most efficient way to store profile images for a social networking website?
what are the difference between for loop & for each loop in php
Is there a website where they have PHP 5 exercise and problems for the beginner? [duplicate]
flex actionscript not uploading file to PHP page HELP!
PHP FTP Upload thousands of files
The css is not displayed in opera mini and balckberry browsers
How to list rows for a query or display 'no records' using a single query
I'm looking for a textbook based introduction to the php 5? Any suggestions? [closed]
getting jquery autocomplete to pass item to another field when selected

Categories

HOME
jboss
generics
functional-programming
exchange-server
workflow
selenium-builder
mousemove
haproxy
gallery
google-sheets-query
openflow
moodle-api
amp
video-streaming
clone
stored-procedures
firebase-database
angular2-template
stack-overflow
xades4j
locationmanager
csrf
supervisord
reselect
pygobject
rpmbuild
azure-machine-learning
stackexchange.redis
uislider
quantitative-finance
vuforia
jpa-2.1
bonita
opnet
delayed-job
wampsharp
lxml
osx-lion
listjs
cloveretl
image-optimization
polyml
subclassing
telephonymanager
text-decorations
assemblies
flowchart
fluid-mac-app-engine
spooler
virtual-memory
rm
md5-file
non-linear-regression
phppgadmin
amazon-elastic-beanstalk
visual-format-language
simple-schema
swiperefreshlayout
degrees
rustdoc
instafeedjs
allegro
boost-compute
carmen
seccomp
jtag
persistent-object-store
seadragon
vim-plugin
largenumber
blockquote
supercomputers
modern.ie
dynamics-ax-2012-r2
darwin
explain
erlog
quercus
scala-swing
htmltidy
flurry-analytics
jini
csslint
cpu-time
pre
django-sites
strdup
san
insertion
examine
handshake
android-dialog
server-name
monocross
zend-server-ce
filelock
photo-management
libxslt
downgrade
odac
tabbarcontroller
android-input-method
activex-exe
webclient.uploaddata

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App