I am trying to get information's user from my Facebook app.
I am using the OAuthUserProvider to get the response data :
array(10) { ["id"]=> string(17) "xxxx" ["first_name"]
=> string(6) "xx" ["gender"]
=> string(4) "male" ["last_name"]
=> string(6) "xx" ["link"]
=> string(62) "https://www.facebook.com/app_scoped_user_id/102xxxx4640725/" ["locale"]
=> string(5) "en_US" ["name"]
=> string(13) "xx xx" ["timezone"]
=> int(1) ["updated_time"]=> string(24) "2014-08-17T21:12:52+0000" ["verified"]
=> bool(true) }
It is missing the email and other information. The problem is from my app because when I use other apps it works well. Should I modify my app's setting to get that missed information?
Related
I was using marketing Api for facebook and php-facebook-sdk something.
I was able to create a campaign and adset and upload a video and now I'm on the part wherein I need to create AdCreative. I find it hard to look for a video_data with the correct object story spec or something like that, so I tried creating based on information that I gathered accross the net and here's what I came up with.
try {
$fields = array(
);
$params = array(
'url_tags' => 'utm_source=facebook',
'object_story_spec' => array('page_id' => $page_id, 'video_data' => array('call_to_action' => array('type' => 'WATCH_VIDEO')), 'image_url' => $image_url, 'video_id' => $video_id),
'name' => 'My Bolbs',
'applink_treatment' => 'web_only',
);
$creative = (new AdAccount($ad_account_id))->createAdCreative(
$fields,
$params
);
$creative_id = $creative->id;
} catch (Exception $e) {
echo 'Caught exception: ', $e, "\n";
}
The error it was throwing to me was this
["error"]=>
array(8) {
["message"]=>
string(17) "Invalid parameter"
["type"]=>
string(14) "OAuthException"
["code"]=>
int(100)
["error_subcode"]=>
int(1443048)
["is_transient"]=>
bool(false)
["error_user_title"]=>
string(34) "object_story_spec param is invalid"
["error_user_msg"]=>
string(99) "Object story spec is ill formed. Maybe missing Page ID or creative details, or invalid fields exist"
["fbtrace_id"]=>
string(11) "Hmti64698Rr"
}
I was wondering if I can ask for any advice on how to fix this error.
Thanks and advance thank you to all those who will suggest and give advice.
Your 'object_story_spec' array is not formed correctly.
'image_url' and 'video_id' are out of 'video_data' array.
The correct array should be:
'object_story_spec' => array(
'page_id' => $page_id,
'video_data' => array(
'call_to_action' => array('type' => 'WATCH_VIDEO'),
'image_url' => $image_url,
'video_id' => $video_id
)
)
I have TYPO3 7.6.18 and I am making ajaxDispatcher. I stay on final study. I trying to call $this->bootstrap->run( '', $this->configuration ); but it get an error. I can't know what this error is exactly. But I'm sure problem in this line.
My $this->configuration is:
array(8) {
["pluginName"] => string(7) "Piphoto"
["vendorName"] => string(5) "Istar"
["extensionName"] => string(7) "feFiles"
["controller"] => string(5) "Photo"
["action"] => string(4) "test"
["mvc"] => array(1) {
["requestHandlers"] => array(1) {
["TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler"] =>
string(48) "TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler"
}
}
["settings"] => array(2) {
["adminemail"] => string(15) "mvnaz#yandex.ru"
["pageShowPhotoId"] => string(2) "32"
}
["persistence"] => array(1) {
["storagePid"] => string(2) "31"
}
}
Action test is allowed in local_conf. The Vendor is set right, extension name, plugin and controller too.
Sorry)
["extensionName"]=>
string(7) "fefiles"
fefiles need Fefiles - uppercase!
Thank you all for help! )
I have the following code:
$fb = new Facebook([
'app_id' => $appId,
'app_secret' => $appSecret,
'default_graph_version' => 'v2.9',
]);
$oAuth2Client = $fb->getOAuth2Client();
$tokenMetaData = $oAuth2Client->debugToken($accessToken);
dump($tokenMetaData);
$graphUser = $fb->get('/me?fields=first_name,last_name,email', $accessToken)->getGraphUser()->asArray();
dump($graphUser);
The output for the above is the following:
$metaData:
[
"app_id" => "..."
"application" => "My App Name"
"expires_at" => "2017-07-01 11:40:09.000000"
"is_valid" => true
"issued_at" => "2017-05-02 11:40:09.000000"
"metadata" => array:2 [
"auth_type" => "rerequest"
"sso" => "ios"
]
"scopes" => array:2 [
0 => "email"
1 => "public_profile"
]
"user_id" => "102..."
]
}
$graphUser:
array:3 [
"first_name" => "John"
"last_name" => "Smith"
"id" => "102...",
]
As you can see, the scopes in $metaData clearly has email so it isn't a permission issue. Despite this, the graph user sometimes does not have the email (although in some cases it does).
Why is this and how can I solve this issue?
Add the fields you need to the URL of your request:
https://graph.facebook.com/me?fields=email,name
First check if your access token gets the user's permission for the email
https://graph.facebook.com/me/permissions?
access_token=(access-token)
&debug=all
if in the answer, this content does not appear:
{
"data": [
{
"permission": "email",
"status": "granted"
},
{
"permission": "public_profile",
"status": "granted"
}
]
}
Maybe in obtaining your access token I do not request mail ownership: Add scope=email to the request
https://www.facebook.com/v2.10/dialog/oauth?
client_id=(app-id)
&redirect_uri=(redirect-uri)
&scope=email
One possibility which i came across today is, if i am registering a account where i am not logging in using my email ID, may be using mobile number to login, and even in my profile primary email is not set or set to a mobile number, in this case facebook returns null for email.
I have updated the account and added email to primary email field under settings in facebook page, then i was able to get the email id from facebook.
Hope this helps someone.
Happy coding...
You have to check these steps.
check if your access token gets the user's permission for the email . for that login to your developer account of your app, then tools->graph api explorer then enable user's permission for the email.
check the facebook version, use the latest version.
add email scope in face book login script as below
app.get(
'/auth/facebook',
passport.authenticate('facebook', {
scope: ['user_location', 'email', 'user_friends']
})
);
or
FB.login(function(response) {
// your ajax script
},{
scope: 'email',
return_scopes: true
});
Goto your app > App review > Permissions and Features
Request Advanced access for email which should turn Standard Access into Advanced Access
I solved this issue by specifying the graph api version.
My requested fields first_name,last_name,email,picture
To url: https://graph.facebook.com/me
Did NOT return email.
To url: https://graph.facebook.com/v2.9/me
Did return email.
Hope this helps.
I tried to implement Create Account API of paypal with the following sample parameters:
accountType=Premier&addressType.line1=Real+St&addressType.city=San+Jose&addressType.postalCode=92274&addressType.countryCode=US&addressType.state=California&citizenshipCountryCode=US&contactPhoneNumber=123-456-1234&homePhoneNumber=123-456-1234&mobilePhoneNumber=123-456-1234¤cyCode=USD&dateOfBirth=1970-01-01Z&emailAddress=test.test%40gmail.com&nameType.salutation=Miss&nameType.firstName=Malou&nameType.lastName=Perez&nameType.suffix=Sr&preferredLanguageCode=en_US®istrationType=Web&requestEnvelope.errorLanguage=en_US&requestEnvelope.detailLevel=ReturnAll&suppressWelcomeEmail=1&createAccountWebOptionsType.useMiniBrowser=0&createAccountWebOptionsType.returnUrl=http%3A%2F%2Fwww.testurlonly.com&createAccountWebOptionsType.reminderEmailFrequency=NONE&createAccountWebOptionsType.confirmEmail=0
To make it clearer, parameters when put in array has the following values:
$parameters = array(
'accountType' => 'Premier',
'addressType.line1' => 'Real St',
'addressType.city' => 'San Jose',
'addressType.postalCode' => '92274',
'addressType.countryCode' => 'US',
'addressType.state' => 'California',
'citizenshipCountryCode' => 'US',
'contactPhoneNumber' => '123-456-1234',
'homePhoneNumber' => '123-456-1234',
'mobilePhoneNumber' => '123-456-1234',
'currencyCode' => 'USD',
'dateOfBirth' => '1970-01-01Z',
'emailAddress' => 'test.test#gmail.com',
'nameType.salutation' => 'Miss',
'nameType.firstName' => 'Malou',
'nameType.lastName' => 'Perez',
'nameType.suffix' => 'Sr',
'preferredLanguageCode' => 'en_US',
'registrationType' => 'Web',
'requestEnvelope.errorLanguage' => 'en_US',
'requestEnvelope.detailLevel' => 'ReturnAll',
'suppressWelcomeEmail' => true,
'createAccountWebOptionsType.useMiniBrowser' => false,
'createAccountWebOptionsType.returnUrl' => 'http://www.testurlonly.com',
'createAccountWebOptionsType.reminderEmailFrequency' => 'NONE',
'createAccountWebOptionsType.confirmEmail' => false
);
here is the response of AdaptiveAccounts/CreateAccount api (converted to array):
array(18) {
["responseEnvelope.timestamp"]=>
string(29) "2013-01-07T21:33:01.984-08:00"
["responseEnvelope.ack"]=>
string(7) "Failure"
["responseEnvelope.correlationId"]=>
string(13) "ae7c9d245cabf"
["responseEnvelope.build"]=>
string(7) "4055066"
["error(0).errorId"]=>
string(6) "580029"
["error(0).domain"]=>
string(8) "PLATFORM"
["error(0).subdomain"]=>
string(11) "Application"
["error(0).severity"]=>
string(5) "Error"
["error(0).category"]=>
string(11) "Application"
["error(0).message"]=>
string(40) "Missing required request parameter: name"
["error(0).parameter(0)"]=>
string(4) "name"
["error(1).errorId"]=>
string(6) "580029"
["error(1).domain"]=>
string(8) "PLATFORM"
["error(1).subdomain"]=>
string(11) "Application"
["error(1).severity"]=>
string(5) "Error"
["error(1).category"]=>
string(11) "Application"
["error(1).message"]=>
string(43) "Missing required request parameter: address"
["error(1).parameter(0)"]=>
string(7) "address"
}
Please enlighten me why it says "Missing required request parameter: address" and "Missing required request parameter: name".
I was thinking addressType.line1=Real+St&addressType.city=San+Jose&addressType.postalCode=92274&addressType.countryCode=US&addressType.state=California
refers to address
and
nameType.salutation=Miss&nameType.firstName=Malou&nameType.lastName=Perez&nameType.suffix=Sr
refers to name.
Thank you.
Instead of nameType., use name.. Thus, we have
name.firstName, name.lastName, name.salutation and name.suffix
and I removed name.salutation because i do not have any idea on what the correct values for this field are.
For addressType., i replace it with adress. Moreover, address.state must have the state code and not the state name.
I also figured out that paypal returns 580022 Invalid request parameter for fields with incorrect format and values. We can not put dummy data for postalCode, city and state that are not existing.
I have the following ZF form element.
$this->addElement('text', 'price', array(
'required' => true,
'label' => 'Price:',
'attribs' => array(
'title' => 'Please enter the value of your artwork'),
'filters' => array('Currency'),
'validators' => array(
array('NotEmpty', true, array(
'messages' => array(
Zend_Validate_NotEmpty::IS_EMPTY =>
"You must enter your artworks price"))),
array('Float', true, array(
'messages' => array(
Zend_Validate_Float::INVALID =>
"You must enter a valid price",
Zend_Validate_Float::NOT_FLOAT =>
"You must enter a valid price"))),
array('GreaterThan', true, array(
'min' => 0.99,
'messages' => array(
Zend_Validate_GreaterThan::NOT_GREATER =>
"You must enter a value of £1.00 or more"))))
));
The last validator is Zend_Validate_GreaterThan which has been set an error message, my problem is that the error message is not displayed on the form when this validator fails. All I get rendered is an empty unordered list!!
<ul>
<li></li>
</ul>
When I check the messages output by zend_form I get the error and the message.
array(1) {
["price"]=>
array(1) {
["notGreaterThan"]=>
string(39) "You must enter a value of £1.00 or more"
}
}
Does anyone know why the message is not being rendered on the form?
Many thanks in advance
Garry
EDIT
The only decorator I am using is a viewscript to render the form, on the form I have.
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'forms/add-item.phtml'))
));
and the viewscript itself.
$attribFilterObj = new Freedom_Zend_Filter_HtmlAttribs();
$attribs = $attribFilterObj->filter($this->element->getAttribs());
?>
<form <?php echo $attribs; ?>>
<dl>
<?php echo $this->element->ArtworkTitle->title->render(); ?>
<?php echo $this->element->ArtworkDescription->description->render(); ?>
<?php echo $this->element->price->render(); ?>
<?php echo $this->element->Genres->render(); ?>
<?php echo $this->element->image->render(); ?>
<?php echo $this->element->add->render(); ?>
</dl>
</form>
EDIT
The output of the var_dump is as follows
array(5) {
["Zend_Form_Decorator_ViewHelper"]=>
object(Zend_Form_Decorator_ViewHelper)#157 (6) {
["_buttonTypes":protected]=>
array(3) {
[0]=>
string(24) "Zend_Form_Element_Button"
[1]=>
string(23) "Zend_Form_Element_Reset"
[2]=>
string(24) "Zend_Form_Element_Submit"
}
["_helper":protected]=>
NULL
["_placement":protected]=>
string(6) "APPEND"
["_element":protected]=>
NULL
["_options":protected]=>
array(0) {
}
["_separator":protected]=>
string(2) "
"
}
["Zend_Form_Decorator_Errors"]=>
object(Zend_Form_Decorator_Errors)#158 (4) {
["_placement":protected]=>
string(6) "APPEND"
["_element":protected]=>
NULL
["_options":protected]=>
array(0) {
}
["_separator":protected]=>
string(2) "
"
}
["Zend_Form_Decorator_Description"]=>
object(Zend_Form_Decorator_Description)#159 (6) {
["_escape":protected]=>
NULL
["_placement":protected]=>
string(6) "APPEND"
["_tag":protected]=>
NULL
["_element":protected]=>
NULL
["_options":protected]=>
array(2) {
["tag"]=>
string(1) "p"
["class"]=>
string(11) "description"
}
["_separator":protected]=>
string(2) "
"
}
["Zend_Form_Decorator_HtmlTag"]=>
object(Zend_Form_Decorator_HtmlTag)#160 (7) {
["_encoding":protected]=>
NULL
["_placement":protected]=>
NULL
["_tag":protected]=>
NULL
["_tagFilter":protected]=>
NULL
["_element":protected]=>
NULL
["_options":protected]=>
array(2) {
["tag"]=>
string(2) "dd"
["id"]=>
array(1) {
["callback"]=>
array(2) {
[0]=>
string(22) "Zend_Form_Element_Text"
[1]=>
string(16) "resolveElementId"
}
}
}
["_separator":protected]=>
string(2) "
"
}
["Zend_Form_Decorator_Label"]=>
object(Zend_Form_Decorator_Label)#161 (6) {
["_placement":protected]=>
string(7) "PREPEND"
["_tag":protected]=>
NULL
["_tagClass":protected]=>
NULL
["_element":protected]=>
NULL
["_options":protected]=>
array(1) {
["tag"]=>
string(2) "dt"
}
["_separator":protected]=>
string(2) "
"
}
}
This is sometimes caused by forgetting to include 'Errors' in the form decorator for the element. If you're using a custom decorator, check that first.
a bit old but check this site http://zendguru.wordpress.com/2008/12/04/handling-zend-framework-form-error-messages/
i believe you have to get the error messages yourselve like and then print them
$errorsMessages = $this->form->getMessages();
I had the same problem, I was only using a ViewScript as you are. This solved it:
($this is in the form class I created)
$this->setDecorators(array(
array('ViewScript',
array('viewScript' => '/formElementViewscripts/editRoughDraft/_form.phtml')),
'Form'
));
You must also add the default 'Form' decorator to your form if you want to be able to receive those messages. I tried looking through the code but I couldn´t pinpoint exactly why.