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

How to loop through Models find from Where clause?
Trying to keep session with curl login in twitter
Code start and end in specific time
Return total values of each column after using datepicker to select a start and end date
file_put_contents on multiple request of XML data
How can i change this select sql statement into another select sql?
This code always return $id but not $first_name [duplicate]
Laravel 5.3 array validation
recursion - How to construct a data tree without ids, data is ambigious.
Submitting a form at 3 different times using PHP
How to share a Laravel app codebase in a Docker container while preserving permissions?
PHP: CSV import into MYSQL is always less than the actual amount of rows in the CSV file?
WP template code runs before action
Set expiry time for laravel jwt dynamically
Htaccess index file, if exists
Stripe differentiation between charge deduction and Subscription assignment in webhook upon charge.succeeded

Categories

HOME
orientdb
firebase
adfs3.0
devexpress
apk
tcp
ontology
business-intelligence
user-defined-types
l20n
google-sites
bazaar
batch-rename
chronicle-queue
plyr
uilocalnotification
spring-annotations
docx4j
credit-card
location-services
netbios
shapeless
quickcheck
gnu-classpath
uivisualeffectview
ng-repeat
assert
selenide
flowchart
klee
web-inspector
jqgrid-asp.net
cloudwatch
return-type
rm
head.js
karabiner
redisson
android-sharing
htmlspecialchars
test-data
alertify
msxml
mpmovieplayercontroller
kendo-treeview
d3v4
gawk
jsonix
ftp-client
traversable
urbit
mathnet
jeditable
mercurial-extension
mnesia
okta-api
ajax4jsf
phpredis
htmltidy
google-hangouts
adhoc-polymorphism
cout
tabletools
xmi
boolean-algebra
ntlmv2
significant-digits
fbml
microblogging
mvcrecaptcha
space-partitioning
webresponse
dip
regression-testing
solandra
urchin
android-input-method
resharper-5.0
gtktextview
xap
activex-exe

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App